Search code examples
flutterdarttextfont-family

Why my font family aint working in Flutter?


Everything seems working just fine except the font family.Text animation is working but everytime i run my Flutter apps it runs on the normal default font.What should i do now?

children: [
        AnimatedTextKit(
          animatedTexts: [
            TypewriterAnimatedText(
              'Hello world!',
              textStyle: const TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.bold,
                  fontFamily: 'Canterbury'
              ),
              speed: const Duration(milliseconds: 200),
            ),
          ],

          totalRepeatCount: 4,
          pause: const Duration(milliseconds: 1000),
          displayFullTextOnTap: true,
          stopPauseOnTap: true,
        )
      ],
    )
  ),
);

} }


Solution

  • Make sure to add the fonts to your pubspec.yaml file. Here is an example of how to properly implement them assuming the file storing your fonts is in the root folder of your project (not the lib)

    assets:
    ...
      fonts:
        - family: Schyler
          fonts:
            - asset: fonts/Schyler-Regular.ttf
            - asset: fonts/Schyler-Italic.ttf
              style: italic