studioLoadFonts function

Future<void> studioLoadFonts()

Loads the face Studio bundles, so the first frame is set in it. Await it before runApp: on the web a bundled face otherwise arrives after the first frames, which flash in a fallback face.

Future<void> main() async {WidgetsFlutterBinding.ensureInitialized(); await studioLoadFonts(); runApp(const MyApp());}

Implementation

Future<void> studioLoadFonts() {
  final loader = FontLoader(studioRegisteredFamily(studioFontFamily));
  for (final (file, _) in _faces) {
    loader.addFont(
      rootBundle.load(
        studioFontPackage == null
            ? 'assets/fonts/$file'
            : 'packages/$studioFontPackage/assets/fonts/$file',
      ),
    );
  }
  return loader.load();
}