android - flutter:自定义字体没有显示效果

标签 android fonts dart flutter

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

这是我的代码

  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,
  ),
);

This is My yaml file

this is my project hierarchy

最佳答案

我认为这与您的 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

关于android - flutter:自定义字体没有显示效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54148340/

相关文章:

java - PdfBox 2.0.3 NullPointerException 在 Linux 上的字体编码

php - 如何在其原始单列中显示第一篇文章,并在两列中显示所有其他文章? WordPress的

flutter - 大量打印是否会使某些 Flutter 代码运行速度变慢?

android - 启动时无法在 Android 应用程序中实例化 fragment

css - Chrome 中的 Web 字体渲染

android - 等待但未抛出 SocketTimeoutException?

dart - Future Builder 制作 Sliver Lists

inheritance - 如何检测对象中分配给 Dart 基类变量的接口(interface)?

android:在浏览器中从网络下载文件时设置 Intent 过滤器以触发 Activity 时出现问题

android - 在 Android 4.4.2 上以编程方式插入短信