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 support for ex units #618
Conversation
…nearGradient, image)
lib/src/svg/theme.dart
Outdated
@override | ||
bool operator ==(dynamic other) { | ||
if (other.runtimeType != runtimeType) { | ||
return false; | ||
if (identical(this, other)) { |
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.
What's the reason for this change?
This class shouldn't really be expensive enough to compare yet to benefit from this.
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.
This method should not be expensive as it would only check whether two references are the same, right? The reason why I wanted to avoid runtimeType
is that I found runtimeType.toString
may have different values under minification and saw some recommendations to avoid it (see here). Let me know if you prefer to keep runtimeType
here.
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.
Yes, runtimeType toString should be avoided but this does not use that. Please change it back
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.
Sure, reverted.
}); | ||
}); | ||
|
||
group( |
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.
Why are we deleting these?
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.
It's because the decoder is now rebuilt only when PictureProvider's theme changes (before PictureProvider had multiple properties like fontSize
and currentColor
, now it's only a theme
that wraps all those properties). Because of that we only need to check if the decoder rebuilds when the theme changes if that makes sense.
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.
Ahh ok
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.
Overall seems fine, a couple small questions
@dnfield I think all your comments should be resolved now. Do you think we can merge this? |
Thanks! |
Adds support for font-relative ex units.
parseDoubleWithUnits
to parse ex units along with px and em.xHeight
toSvgTheme
(defaults to the font size divided by 2).SvgPicture
uses the provided x-height to calculate ex units in SVG elements. If no x-height is provided through the widget's property, then the value fallbacks to (consecutively)DefaultSvgTheme.xHeight
or the font size divided by 2.