为什么cupertino_icons中的图标很少? [英] Why are there so few icons in cupertino_icons?

查看:691
本文介绍了为什么cupertino_icons中的图标很少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个问题。我认为将它们组合在一起可能更明智,因为它们之间的联系非常紧密。

Two questions. I thought it might be wiser to combine them because they are related very closely.

查看 常量 CupertinoIcons 中,我能够确定 CupertinoIcons中有 35 个图标

Looking at the constants of the CupertinoIcons class I was able to make out that there are 35 icons in CupertinoIcons.

文档页面显示有关此地图


此图标字体中的图标的地图。

a map of the icons in this icons font.

我希望所有这些图标也将出现在 CupertinoIcons ,仅缺少 374 ,因为地图上有 409 个图标。

I would expect that all those icons would also be featured in CupertinoIcons, there are just 374 missing as there are 409 icons featured on the map.

对我来说 CupertinoIcons 是s仅使用 35 图标就没用了,我可以在我的 pubspec.yaml cupertino_icons 的情况下进行访问$ c>。

For me CupertinoIcons is slightly useless with just the 35 icons, which I can access without having cupertino_icons in my pubspec.yaml.

我认为安装 cupertino_icons 可能会有所改变。

I figured that installing cupertino_icons might change something.

现在,我安装了 cupertino_icons 插件没有更改 。我仍然可以使用与以前完全相同的 35 图标(并且无论是否显示插件都可以显示它们)。

Now, that I installed the cupertino_icons plugin, nothing changed. I still have access to the exactly same 35 icons as before (and they are being displayed with and without the plugin).

会发生这种情况吗?因为我的设备已经安装了字体,因此不需要 cupertino_icons 插件才能正常工作?

Does this happen because my device already has the font installed and thus does not need the cupertino_icons plugin in order to work?

推荐答案

该插件确保包含必需的资产(字体)。

The plugin makes sure that the necessary assets (fonts) are included.

如果您查看源代码,则可以轻松复制只要在字体中存在常量,就可以在其中定义常量。而且由于Flutter是开源的,因此,如果您在其中确定了其他您认为应该向用户公开的有用图标,则可以肯定会为此创建PR。

If you look at the source, you can easily replicate the constants defined in there as long as they exist in the font. And since Flutter is open source, you could certainly create a PR for that if you identify other useful icons in there that you think should be exposed to users.

为什么...目前可能还没有任何人优先考虑它。查找,命名和显示这些图标是一件繁琐的工作-我想很多这样做的人最终都会想出好,我现在做完了,而不是将其回馈给项目。

As to why ... it probably just hasn't been prioritized by anyone at this point. It's somewhat tedious work to find, name, and expose those icons - and I'd imagine a lot of people that do it just end up figuring "ok I'm done now" rather than contributing it back to the project.

您可以看到字体此处。您可以使用任何这些图标,即使在cupertino图标类中尚未定义它们,也可以使用。例如,如果您出于某些原因想要棒球图标:

You can see a fuller listing of the icons contained in the font here. You could use any of those icons, even if it's not already defined in the cupertino icons class. For example, if you wanted the baseball icon for some reason:

const IconData baseball = const IconData(
  0xf4ba, 
  fontFamily: CupertinoIcons.iconFont, 
  fontPackage: CupertinoIcons.iconFontPackage);

完全有可能将其作为请求请求添加到 https://github.com/flutter/flutter/blob/master/包/flutter/lib/src/cupertino/icons.dart -但我想它不在那儿,因为它不被认为是普遍使用或必需的,或者也许是因为有人还没有去了解它。

It'd be entirely possible to add this as a pull request to https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/cupertino/icons.dart - but I imagine it's not in there because it's not seen as commonly used or necessary, or perhaps because someone didn't get to it yet.

无论哪种方式,您仍然需要cupertino_icons软件包,因为这将确保.ttf文件包含在您的应用程序中(该应用程序需要在运行时呈现图标)。但是,如果您不打算使用它们,请不要包含它,因为它会导致您的应用超出其所需的大小(多余的字体会占用空间)。

Either way, you still need the cupertino_icons package, because that will ensure that the .ttf file is included in your app (which the app will need to render the icon at runtime). But if you don't plan to use them, don't include it, as it will cause your app to be larger than it needs to be (the extra font will take space).

这篇关于为什么cupertino_icons中的图标很少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆