简体   繁体   English

Flutter:如何从图标小部件返回代码点值?

[英]Flutter: howto return the codePoint value from an Icon widget?

I want to bypass an Icon Widget to a custom widget and get the Icons codePoint value make some changes and return the new Icon Widget.我想绕过图标小部件到自定义小部件并获取图标代码点值进行一些更改并返回新的图标小部件。

class NewCustomWidget extends StatefulWidget {
  const NewCustomWidget({
    Key? key,
    this.mySize,
    this.myIcon,
  }) : super(key: key);

  final double? mySize;
  final Icon? myIcon;

  @override
  _NewCustomWidgetState createState() => _NewCustomWidgetState();
}

class _NewCustomWidgetState extends State<NewCustomWidget> {
  @override
  Widget build(BuildContext context) {
    return Icon(
      ???? howto bypass the widget.myIcon's codePoint/IconData to the new Icon ????
      color: Colors.black,
      size: widget.mySize,
    );
  }
}

I tried to use the widget.myIcon.toString() but I get only the String "widget"我尝试使用 widget.myIcon.toString() 但我只得到字符串“widget”

Icon takes IconData. Icon采用 IconData。 You can do你可以做

return Icon(
  widget.myIcon?.icon,
  color: Colors.black,
  size: widget.mySize,
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM