Android 颤振:自定义字体显示无效果

Android 颤振:自定义字体显示无效果,android,fonts,dart,flutter,Android,Fonts,Dart,Flutter,我尝试了很多解决方案,但没有一个是有效的,我尝试了这些解决方案,但仍然字体显示没有效果,应用程序并没有显示任何错误。 代码有什么问题 下面是我的代码 Widget textSection = new Container( decoration: new BoxDecoration( color: Colors.blue[100], border: new Border.all(color: Colors.black)), padding: const EdgeInsets

我尝试了很多解决方案,但没有一个是有效的,我尝试了这些解决方案,但仍然字体显示没有效果,应用程序并没有显示任何错误。 代码有什么问题

下面是我的代码

  Widget textSection = new Container(
  decoration: new BoxDecoration(
      color: Colors.blue[100], border: new Border.all(color: Colors.black)),
  padding: const EdgeInsets.all(18.0),
  margin: const EdgeInsets.only(left: 14.0, right: 14.0, bottom: 14.0),
  width: double.infinity,
  child: new Text(
    "Labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
    textAlign: TextAlign.center,
    style: new TextStyle(
        color: Colors.black45,
        fontSize: 22.0,
        fontFamily: 'Raleway-Regular'),
    softWrap: true,
  ),
);


我认为这与您的pubspec文件有关,缩进很重要

flutter:
  uses-material-design: true
  assets: 
    - image/lake.png
  fonts:
    - family: Raleway
      fonts:
        - asset: fonts/Raleway-Regular.ttf
        - asset: fonts/Raleway-Italic.ttf
          style: italic

您命名了字体系列
ralway
,但在代码中使用了字符串
ralway Regular
。将其中一种更改为另一种,应该可以使用。

我实际上在应用程序中也使用了这种字体。我想你需要为它买一个许可证,但我记不清了。无论如何,您的字体名称如下:

fonts:
    family: Raleway
在这里,您将字体命名为Raleway,因此在颤振代码中,您必须指定完全相同的名称:


fontFamily:“Raleway”

你能发布你的
pubspec.yaml
文件(代码格式)吗?更正你的身份并运行
flatter clean
确保创建一个新的
/build
文件夹