Flutter-调用自定义图标字形的正确方法是什么? [英] Flutter - what is correct way to invoke custom icon glyph?
本文介绍了Flutter-调用自定义图标字形的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在pubspec.yaml(icomoon.ttf)中声明了自定义图标字体.
I have declared a custom icon font in pubspec.yaml (icomoon.ttf).
Flutter的文档说要调用图标,使用...
Flutter's documentation says to invoke an icon, use...
const IconData(
this.codePoint, {
this.fontFamily,
});
我有一个带有填充的元素,其中应该包含图标.
I have an element with padding that should contain the icon.
new Padding(
padding: new EdgeInsets.only(top: 2.0),
how to invoke the glyph here? Need to be able to specify font size and
color too.
),
我应该如何调用颜色为"myColor"的大小为25px的"icomoon.ttf"字形"e901"?
What is an example of how I should invoke "icomoon.ttf" glyph "e901" at size 25px with tint "myColor"?
推荐答案
您需要在 Icon
小部件中使用该 IconData
来显示它,例如:>
You need to use that IconData
in an Icon
widget to display it, something like:
new Icon(const IconData(0x41, fontFamily: 'Roboto'), size: 48.0, color: Colors.red);
因此,在您的情况下,它将类似于:
So in your case it would be something like:
new Icon(const IconData(0xe901, fontFamily: 'icomoon'), size: 25.0, color: myColor);
这篇关于Flutter-调用自定义图标字形的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文