How to use available browser fonts in a Flutter web app

117

You can use Google font package

https://pub.dev/packages/google_fonts

Share:
117
cjmarques
Author by

cjmarques

Updated on December 22, 2022

Comments

  • cjmarques
    cjmarques over 1 year

    I'd like to use fonts that are available in the browser, like all the standard font families. But specifying the font family isn't changing my fonts.

    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'flutter web app',
          theme: ThemeData(
            primarySwatch: Colors.blue,
            textTheme: TextTheme(bodyText2: TextStyle(fontFamily: 'Courier New'))
    
          ),
          home: HomeView(),
        );
      }
    }
    

    How do I use available fonts without having to download and add the fonts to the project?

  • cjmarques
    cjmarques almost 3 years
    Thank you. The package is perfect and easy to use.