Created
November 21, 2023 05:58
-
-
Save KoheiKanagu/2cd9fbd379f2a8e5195a70af70e6ac17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> loadAppFonts() async { | |
final fontManifest = await rootBundle.loadStructuredData( | |
'FontManifest.json', | |
(string) async => json.decode(string) as Iterable<dynamic>, | |
); | |
for (final e in fontManifest) { | |
final loader = FontLoader( | |
(e as Map<String, dynamic>)['family'] as String, | |
); | |
for (final f in e['fonts'] as List<dynamic>) { | |
loader.addFont( | |
rootBundle.load((f as Map<String, dynamic>)['asset'] as String), | |
); | |
} | |
await loader.load(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment