loadFonts function
Load fonts to make sure they show up in golden tests.
To use it efficiently:
- Create a flutter_test_config.dart file. See: https://api.flutter.dev/flutter/flutter_test/flutter_test-library.html
- add
await loadFonts();
in thetestExecutable
function.
Note for this function to work, your package needs to include all fonts it uses in a font dir at the root of the project.
Implementation
Future<void> loadFonts([String? package]) async {
return package != null
? loadFontsFromPackage(
package: Package(name: package, relativePath: './$package'),
)
: loadFontsFromPackage();
}