loadAppFonts function

Future<void> loadAppFonts()

By default, flutter test only uses a single "test" font called Ahem.

This font is designed to show black spaces for every character and icon. This obviously makes goldens much less valuable.

To make the goldens more useful, we will automatically load any fonts included in your pubspec.yaml as well as from packages you depend on.


Future<void> loadAppFonts() async {
  final fontManifest = await rootBundle.loadStructuredData<Iterable<dynamic>>(
    (string) async => json.decode(string),

  final loaders = <FontLoader>[];
  for (final Map<String, dynamic> font in fontManifest) {
    final fontLoader = FontLoader(derivedFontFamily(font));
    for (final Map<String, dynamic> fontType in font['fonts']) {

  await Future.wait(loaders.map((loader) => loader.load()));