flutter bottomNavigationBar和自定义字体问题

时间:2019-05-14 19:10:44

标签: flutter

我尝试使用自定义字体创建bottomNavigationBar,但应用程序崩溃。

如果删除bottomNavigationBar,则Text小部件会正确显示为带有字体,但在添加bottomNavigationBar应用后崩溃。

flutter版本

Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E226, locale en-IR)

代码

@override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xffF6F8FA),
      bottomNavigationBar: BottomNavigationBar(items: [
        BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("Tab 1",style: TextStyle(fontFamily: "iransans"),)),
        BottomNavigationBarItem(icon: Icon(Icons.beach_access), title: Text("Tab 2",style: TextStyle(fontFamily: "iransans"),)),
        BottomNavigationBarItem(icon: Icon(Icons.offline_bolt), title: Text("Tab 3",style: TextStyle(fontFamily: "iransans"),)),
      ]),
      body: Container(
        child: Center(
          child: Text("Hello from tab 1"),
        ),
      ),
    );
  }

错误

[VERBOSE-2:FontFamily.cpp(184)] Could not get cmap table size!
[VERBOSE-2:FontFamily.cpp(184)] Could not get cmap table size!
[VERBOSE-3:FontCollection.cpp(95)] nTypefaces == 0

2 个答案:

答案 0 :(得分:0)

如果您已将字体添加到pubspec.yaml文件中,并且使用的是iOS模拟器,则此问题与Github页面(Here)上提到的问题非常相似。

答案 1 :(得分:0)

就我而言,我忘记在uses-material-design: true文件的flutter之后添加pubspec.yml