【发布时间】:2019-11-05 15:48:51
【问题描述】:
我正在为浮动操作按钮使用材料设计图标。 现在我想使用自定义图标。从 SVG 文件中,我使用 Flutter-Icon-Generator (http://fluttericon.com/) 生成了一个字体。一切正常,但图标未居中。
这里是最小化的截图,€-Icon居中,另一个(自定义)不是:
FloatingActionButton的对应代码为:
Widget money() {
return Container(
child: FloatingActionButton(
backgroundColor: widget.openColor,
elevation: 0,
heroTag: "btn_money",
onPressed: () {
widget.onPressed(DashboardFabAction.AddMoney);
animate();
},
tooltip: 'Money',
child: Icon(Icons.euro_symbol, color: widget.iconColorOpen,),
),
);
}
Widget eggs() {
return Container(
child: FloatingActionButton(
backgroundColor: widget.openColor,
elevation: 0,
heroTag: "btn_eggs",
onPressed: () {
widget.onPressed(DashboardFabAction.AddEggs);
animate();
},
tooltip: 'Eggs',
child: Icon(CustomIcons.egg, color: widget.iconColorOpen,),
),
);
}
CustomIcons 的代码是:
import 'package:flutter/widgets.dart';
class CustomIcons {
CustomIcons._();
static const _kFontFam = 'CustomIcons';
static const IconData egg = const IconData(0xe800, fontFamily: _kFontFam);
}
pubspec.yaml 在这里并不有趣,因为我在那里得到了正确的图标。
提前感谢您的回答!
【问题讨论】:
-
谢谢你的信息,但对我来说没有用。顺便说一句,我不是 SVG 专家