loadFontsFromPackage function

Future<void> loadFontsFromPackage({
  1. Package? package,
})

Load fonts from a given package to make sure they show up in golden tests.

To use it efficiently:

Note for this function to work, your given package needs to include all fonts it uses in a font dir at the root of the project referenced by the given package argument. If no package is provided, it will look for a fonts dir at the root of the project. If a package is provided with a Package.relativePath it will look for a fonts dir with the package located at that path If a package is provided with a Package.name it will prefix the fonts dir with packages/[package.name]

Implementation

Future<void> loadFontsFromPackage({Package? package}) async {
  TestWidgetsFlutterBinding.ensureInitialized();
  await _load(loadFontsFromFontsDir(package));
  await _loadMaterialIconFont();
}