fontAwesome 图标在我的 flutter 应用程序中不起作用

Kar*_*rar 11 font-awesome flutter

我目前正在做一个副项目,当我在我的应用程序中包含一个字体很棒的图标时,它没有显示出来,而是一个空白框,两条线像字母 x 一样相互交叉,如何解决这个问题?

class ImageHoldingComponent extends StatefulWidget {
  @override
   _ImageHoldingComponentState createState() => 
 _ImageHoldingComponentState();
Run Code Online (Sandbox Code Playgroud)

}

class _ImageHoldingComponentState extends State<ImageHoldingComponent> {
  @override
  Widget build(BuildContext context) {
    return Container(
   child: Icon(FontAwesomeIcons.python)
      );
  }
}
Run Code Online (Sandbox Code Playgroud)

Maz*_*him 33

font_awesome_flutterpackage的作者为任何图标未显示问题的人建议以下步骤:

  1. 停止应用程序
  2. 在您的应用程序目录中运行 flutter clean
  3. 从模拟器/模拟器/设备中删除应用程序
  4. 重建和部署应用程序。

还要确保在 pubspec.yaml 文件中设置uses-material-designtrue


小智 6

当您开始使用旧版本的 font_awesome_flutter 时,就会发生这种情况,因为虚拟设备缓存是在构建 Flutter 应用程序时存储的,因此每次更改图标时,您都必须停止模拟器并重建它。

我的经验是:

  1. 停止main.dart(Android 模拟器)

  2. 添加pubspec.yaml(font_awesome_flutter)新版本

font_awesome_flutter:^8.8.1

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  font_awesome_flutter: ^8.8.1 //new verison
Run Code Online (Sandbox Code Playgroud)

然后单击

“酒吧得到”

在 Flutter 命令的顶部

  1. 再次运行模拟器(启动main.dart)