flutterfontsgoogle-fonts

How do I use google fonts on defining a theme in flutter


I am new to flutter.

I installed this library to be able to use google fonts.

Now I need to do it in the theme data definition, and tried like this but it's not allowed

ThemeData appTheme() {
  return ThemeData(
    ...
    fontFamily: GoogleFonts.openSans(),
  );
}

How do I do this? Thank you very much


Solution

  • Reposting my comment: fontFamily expects a String. Use GoogleFonts.openSans().fontFamily.