Home > Enterprise >  Error: unable to locate asset entry in pubspec.yaml: "lib/fonts/IndieFlower-Regular.ttf"
Error: unable to locate asset entry in pubspec.yaml: "lib/fonts/IndieFlower-Regular.ttf"

Time:02-08

Error: unable to locate asset entry in pubspec.yaml: "lib/fonts/IndieFlower-Regular.ttf".

FAILURE: Build failed with an exception.

  • Where: Script 'D:\Flutter project\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1070

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'D:\Flutter project\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 12s Exception: Gradle task assembleDebug failed with exit code 1

CodePudding user response:

Welcome to Stackoverflow, Mohamed!

You have to create an assets folder outside the lib directory, in the root of your project and then put the fonts folder in it.

After that, in the pubspec.yaml add these lines in the flutter section:

flutter:

  fonts:
    - family: font_name
      fonts:
        - asset: assets/fonts/font_name.ttf

You can read more about fonts in the Flutter from the official documentation.

CodePudding user response:

You can add fonts like this way in the pubsec.yml file you can take reference through this article I am sharing with you. https://soshace.com/how-to-add-custom-fonts-in-flutter/

https://youtu.be/fDRtpjHfOuw

flutter:
  fonts:
    - family: DancingScript     
      fonts:
        - asset: assets/fonts/DancingScript-Regular.ttf
    - family: Langer     
      fonts:
        - asset: assets/fonts/Langar-Regular.ttf
  •  Tags:  
  • Related