在Flutter中添加自定义字体时,我没有收到错误,但它没有应用字体。
我已经尝试了完整的重建,重新安装,以及我从其他类似线程中读到的东西,但到目前为止都没有起作用。这是我的pubspec.yaml的一部分
flutter:
  uses-material-design: true
  fonts:
    - family: Bauhaus
      fonts:
        - asset: fonts/Bauhaus.ttf下面是一个代码示例。
                        new TextSpan(
                          text: 'Started!', 
                          style: new TextStyle(
                            decoration: TextDecoration.none,
                            fontSize: 50.0,
                            fontFamily: "Bauhaus",
                            color: Colors.red,
                          ),
                        ),它适用于默认的东西,如"Times New Roman",但不是自定义字体。
发布于 2019-10-23 09:11:17
运行主函数后,您尚未配置主题
如下所示:
fonts:
    - family: SFUIText
      fonts:
        - asset: assets/fonts/SFUIText-Regular.ttf
        - asset: assets/fonts/SFUIText-Semibold.ttf
          weight: 600
        - asset: assets/fonts/SFUIText-RegularItalic.ttf
          style: italic
final app = MaterialApp(
      theme: ThemeData(
          primaryIconTheme: const IconThemeData(color: mColorIcon),
          primaryColor: mColorPrimary,
          accentColor: mColorAccent,
          backgroundColor: mColorBackground,
          indicatorColor: mColorPrimary,
          splashColor: mColorPrimary,
          canvasColor: mColorCanvas,
          appBarTheme: Styles.appBar,
          fontFamily: 'SFUIText',
          textTheme: TextTheme(
              title: Styles.title,
              body1: Styles.textSecondary,
              body2: Styles.textSecondaryBold,
              headline: Styles.headline,
              subhead: Styles.subHeading,
              button: Styles.button,
              overline: Styles.overline)), ...);https://stackoverflow.com/questions/58512616
复制相似问题