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
Add ability to wait for fonts to load with GoogleFonts.pendingFonts
#195
Conversation
lib/src/google_fonts_base.dart
Outdated
@@ -99,7 +107,9 @@ TextStyle googleFontsTextStyle({ | |||
file: fonts[matchedVariant]!, | |||
); | |||
|
|||
loadFontIfNecessary(descriptor); | |||
final loadingFuture = loadFontIfNecessary(descriptor); |
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.
test cases would be nice to validate what this behaves like when loading the font isn't necessary, for instance
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.
I think this has been covered by load_font_if_necessary_with_local_fonts_test.dart
.
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.
Otherwise LGTM as an initial functionality. Brain is a bit foggy, but can't think of a way to avoid pendingFontLoadsInternal
instead of return a |
Hey @johnsonmh and @guidezpl, I would really appreciate if someone had the time to finish this PR in the near future. It's an awesome feature, and you are doing amazing work 💙😄 |
This comment was marked as off-topic.
This comment was marked as off-topic.
@johnsonmh is this still valid? |
heyla! it's approved!! pls merge it |
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.
Agree with changes proposed by @clocksmith and testing is still required before merging
Hey @guidezpl, can you take another pass at this when you get a chance? Thanks! |
It's been 2 years. What happened? Can we merge it? 😄 |
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.
I've taken over the PR and made improvements, approving to unblock landing.
GoogleFonts.pendingFonts
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.
LGTM
Generally how long does it take for a merge like this to be available in the package? |
I'm going to fix #102 and then release :) |
Description
GoogleFonts.pendingFonts
returns aFuture
which resolves when requested fonts have finished loading and are ready to be rendered on screen.This can be used in combination with a
FutureBuilder
to avoid visual font swappingThis PR includes these changes:
FutureBuilder
in exampleRelated Issues
Tests
Fixes #151
Future work
preloadX
functions for each text style and text theme. Currently it is not possible to tell which font loads when.