npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flutter-iconfont-cli-opacity

v1.2.2

Published

用纯JS把iconfont.cn的图标转换成Flutter Widget,不依赖字体,支持多色彩

Downloads

14

Readme

flutter-iconfont-cli

用纯JS把iconfont.cn的图标转换成Flutter Widget,不依赖字体,支持多色彩

特性

1、纯组件,不依赖字体,体积小 2、支持渲染多色彩图标,支持自定义颜色 3、自动化生成图标组件

Step 1

在项目文件pubspec.yml中加入flutter插件 flutter_svg

{
  ...

  dependencies:
    # 版本号请以官方库的为准:https://pub.dev/packages/flutter_svg
    flutter_svg: ^0.19.3
  ...
}

然后执行flutter插件安装操作

flutter packages get

接着安装全局插件(基于nodeJs)

npm install flutter-iconfont-cli -g

Step 2

生成配置文件

npx iconfont-init

此时项目根目录会生成一个iconfont.json的文件,内容如下:

{
    "symbol_url": "请参考README.md,复制官网提供的JS链接",
    "save_dir": "./lib/iconfont",
    "trim_icon_prefix": "icon",
    "default_icon_size": 18,
    "null_safety": true
}

配置参数说明:

symbol_url

请直接复制iconfont官网提供的项目链接。请务必看清是.js后缀而不是.css后缀。如果你现在还没有创建iconfont的仓库,那么可以填入这个链接去测试:http://at.alicdn.com/t/font_1373348_ghk94ooopqr.js

save_dir

根据iconfont图标生成的组件存放的位置。每次生成组件之前,该文件夹都会被清空。

trim_icon_prefix

如果你的图标有通用的前缀,而你在使用的时候又不想重复去写,那么可以通过这种配置这个选项把前缀统一去掉。

default_icon_size

我们将为每个生成的图标组件加入默认的字体大小,当然,你也可以通过传入props的方式改变这个size值

null_safety

dart 2.12.0 开始支持的空安全特性,开启该参数后,生成的语法会有所变化,所以需要变更sdk以保证语法能被识别。

environment:
- sdk: ">=2.7.0 <3.0.0"
+ sdk: ">=2.12.0 <3.0.0"

Step 3

开始生成React标准组件

npx iconfont-flutter

生成后查看您设置的保存目录中是否含有所有的图标


现在,你可以参考snapshots目录的快照文件。

使用

图标尺寸

根据配置default_icon_size,每个图标都会有一个默认的尺寸,你可以随时覆盖。

class App extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
        return IconFont(IconNames.alipay, size: 100);
    }
}

图标单色

单色图标,如果不指定颜色值,图标将渲染原本的颜色。如果你想设置为其他的颜色,那么设置一个你想要的颜色即可。

注意:如果你在props传入的color是字符串而不是数组,那么即使原本是多色彩的图标,也会变成单色图标。

IconFont(IconNames.alipay, color: 'red');

图标多色彩

多色彩的图标,如果不指定颜色值,图标将渲染原本的多色彩。如果你想设置为其他的颜色,那么设置一组你想要的颜色即可

IconFont(IconNames.alipay, colors: ['green', 'orange']);

颜色组的数量以及排序,需要根据当前图标的信息来确定。您需要进入图标组件中查看并得出结论。

更新图标

当您在iconfont.cn中的图标有变更时,只需更改配置symbol_url,然后再次执行Step 3即可生成最新的图标组件

# 修改 symbol_url 配置后执行:
npx iconfont-flutter

扩展

|平台|库| |----|---| |小程序|mini-program-iconfont-cli| |Taro|taro-iconfont-cli| |React H5|react-iconfont-cli| |React Native|react-native-iconfont-cli| |Remax|remax-iconfont-cli|


欢迎使用,并给我一些反馈和建议,让这个库做的更好