Search code examples
flutterdartyaml

I don't know why frontfamily doesn't work?


I've tried a lot of things but I can't figure out why I can't change the font. I'm trying to train myself in dart to learn but I really don't understand why, I don't get any error messages, nothing, I don't understand why it's doing this ... Please help me if possible. If you need more information don't hesitate.

dart

yaml

  • Thanks

I've checked the path several times and changed the font but nothing works.


Solution

  • This sort of issues occurs sometimes due to spacing. Because yml files are extremely space sensitive moreover you are using underscores in file name as well which is producing this issue according to me so remove the spacing and then rebuild.

    Both font name and file should be same. Change the name to your font

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

    Use the same name you have written in family inside text font family.

    static const TextStyle chatbotWelcomeHeadingStyle = TextStyle(
        fontWeight: FontWeight.w700,
        color: AppColors.blackColor,
        fontSize: 26,
        fontFamily: "LibreBaskervilleRegular",
      );
    

    Now simply run the flutter clean and flutter pub get and problem should be solved. Do give the thumbs up if it helps :) Happy Coding