【发布时间】:2020-09-23 02:52:53
【问题描述】:
我在我的应用程序中使用 Material Icons 和 Font Awesome Icons,试图使它们的大小相同。我不知道 Material Icons 是否有填充,但对我来说它们的大小似乎不同。
相关问题和关于它的 SO 帖子:
- https://stackoverflow.com/a/54933040/9779791
- https://github.com/flutter/flutter/issues/24054
- https://github.com/flutter/flutter/issues/34958
-
https://github.com/fluttercommunity/font_awesome_flutter/issues/23
@override Widget build(BuildContext context) { return Container( width: 24, height: 24, decoration: BoxDecoration( shape: BoxShape.circle, color: blueColor, ), child: Container( width: 15, height: 15, child: Icon( iconData, color: Colors.white, ), ), ); } }
我将Icons.directions_run 和FontAwesomeIcons.mountain 与我的自定义小部件一起使用(我需要它们的圆形背景,欢迎提出建议),但我无法使它们的大小相同。
这是它们在调试绘画中的外观:
我还从Icon 中删除了size,并使用另一个Container 来调整图标大小。这是代码:
class ChallengeDetailIcon extends StatelessWidget {
const ChallengeDetailIcon({@required this.iconData});
final IconData iconData;
@override
Widget build(BuildContext context) {
return Container(
width: 24,
height: 24,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: blueColor,
),
child: Container(
width: 15,
height: 15,
child: Icon(
iconData,
color: Colors.white,
),
),
);
}
}
但是没有用。
编辑:试过FaIcon
代码:
@override
Widget build(BuildContext context) {
return Container(
width: 24,
height: 24,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: blueColor,
),
child: Center(
child: FaIcon(
iconData,
size: 12,
color: Colors.white,
),
),
);
}
}
【问题讨论】:
标签: flutter