Add error message when lerping between TextStyles different inherit values#112837
Conversation
There was a problem hiding this comment.
I wonder if I should mention this is just mimicking Theme.of. Maybe there're better examples?
There was a problem hiding this comment.
This error report is probably comprehensive enough without this additional explanation. Also: it's not clear that we really want to advocate calling ThemeData.localize, since that's done automatically when the app's locale is finalized. I think it would be best to leave this part of the error report out.
There was a problem hiding this comment.
There's no ThemeData.merge so the example is really awkward. Should I say instead of transitioning to Theme.of(context) you should transition to isDark ? ThemeData.dark() : ThemeData()?
282de92 to
df34286
Compare
HansMuller
left a comment
There was a problem hiding this comment.
LGTM. Just some wordsmithing and error message smithing.
| /// [inherit] value. | ||
| /// | ||
| /// Properties that don't have explicit values or other default values to fall | ||
| /// back to will revert to the defaults defined in the text shaper: white in |
There was a problem hiding this comment.
"text shaper"? Will developers know what that refers to? Unless "text shaper" refers to something that will make this point easier to understand, just explaining what the defaults are is probably enough.
Note also: I'm surprised that the default color is white (instead of black).
There was a problem hiding this comment.
I mostly copied these defaults without actually checking (the font size is correct). It could be black let me check.
There was a problem hiding this comment.
yeah it's correct. Should I say "defined in ui.Paragraph" instead?
There was a problem hiding this comment.
got rid of "text shaper"
| /// The package name should be provided by the `package` argument in the | ||
| /// constructor. | ||
| List<String>? get fontFamilyFallback => _package != null && _fontFamilyFallback != null ? _fontFamilyFallback!.map((String str) => 'packages/$_package/$str').toList() : _fontFamilyFallback; | ||
| List<String>? get fontFamilyFallback => _package != null ? _fontFamilyFallback?.map((String str) => 'packages/$_package/$str').toList() : _fontFamilyFallback; |
There was a problem hiding this comment.
This might be slightly easier to ready if the simple case was first:
List<String>? get fontFamilyFallback => _package == null ? _fontFamilyFallback : _fontFamilyFallback?.map((String str) => 'packages/$_package/$str').toList();| } | ||
|
|
||
| /// Interpolate between two text styles. | ||
| /// Interpolate between two text styles for animated transitions. |
There was a problem hiding this comment.
Why include the "for animation transitions" qualifier?
There was a problem hiding this comment.
The implementation does things to keep the transition smooth (e.g.: fontSize: ui.lerpDouble(a.fontSize ?? b.fontSize, b.fontSize ?? a.fontSize, t),), that doesn't really make sense for anything other than transitions.
| /// Interpolate between two text styles. | ||
| /// Interpolate between two text styles for animated transitions. | ||
| /// | ||
| /// This will not work well if the styles don't set the same fields. When this |
There was a problem hiding this comment.
| /// This will not work well if the styles don't set the same fields. When this | |
| /// Interpolation will not work well if the styles don't specify the same fields. When this |
| /// Interpolate between two text styles for animated transitions. | ||
| /// | ||
| /// This will not work well if the styles don't set the same fields. When this | ||
| /// happens, to keep the transition smooth, the implementation uses the |
There was a problem hiding this comment.
| /// happens, to keep the transition smooth, the implementation uses the | |
| /// happens, to keep the interpolated transition smooth, the implementation uses the |
| ErrorSpacer(), | ||
| ErrorHint( | ||
| 'In general, TextStyle.lerp only works well when both TextStyles have ' | ||
| 'the same "inherit" value, and set roughly the same fields.', |
There was a problem hiding this comment.
| 'the same "inherit" value, and set roughly the same fields.', | |
| 'the same "inherit" value, and specify roughly the same fields.', |
Also: Do we really need to say "roughly" the same fields?
There was a problem hiding this comment.
removed roughly
There was a problem hiding this comment.
This error report is probably comprehensive enough without this additional explanation. Also: it's not clear that we really want to advocate calling ThemeData.localize, since that's done automatically when the app's locale is finalized. I think it would be best to leave this part of the error report out.
…lutter into text-style-lerp-guards
Fixes #43358
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.