-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[google_fonts] Add google_fonts_lite file to allow tree-shaking of the other huge files #11433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import 'google_fonts_base.dart'; | ||
| import 'google_fonts_descriptor.dart'; | ||
| import 'google_fonts_variant.dart'; | ||
|
|
||
| // Hosts a Map<String, Map<GoogleFontsVariant, GoogleFontsFile>> where the String is the font's name. | ||
| // That is used to allow tree-shaking to remove all of the _parts files. | ||
| // If you only call GoogleFontsLite.fontsMap or GoogleFontsLite.loadFont(), | ||
| // the code in the GoogleFonts class and its parts classes is never called. | ||
| // WHat is called is googleFontsTextStyle, which attempts to load a font if not already loaded. | ||
| class GoogleFontsLite { | ||
| static Map<String, Map<GoogleFontsVariant, GoogleFontsFile>> fontsMap = { | ||
| {{#fontEntries}} | ||
| '{{fontFamily}}': { | ||
| {{#fontUrls}} | ||
| const GoogleFontsVariant(fontWeight: FontWeight.w{{variantWeight}}, fontStyle: FontStyle.{{variantStyle}},) : const GoogleFontsFile('{{hash}}', {{length}},), | ||
| {{/fontUrls}} | ||
| }, | ||
| {{/fontEntries}} | ||
| }; | ||
|
Comment on lines
+12
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider making |
||
|
|
||
| static TextStyle getFont(String fontFamily) { | ||
| return googleFontsTextStyle(fontFamily: fontFamily, fonts: fontsMap[fontFamily]!); | ||
| } | ||
|
Comment on lines
+23
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "WHat" should be "What".