Skip to content

Commit d7b564a

Browse files
committed
Support decimal percentages for font size
1 parent b0abb3c commit d7b564a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/src/css_parser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ class ExpressionMapping {
621621
if (value is css.NumberTerm) {
622622
return FontSize(double.tryParse(value.text));
623623
} else if (value is css.PercentageTerm) {
624-
return FontSize.percent(int.tryParse(value.text)!);
624+
return FontSize.percent(double.tryParse(value.text)!);
625625
} else if (value is css.EmTerm) {
626626
return FontSize.em(double.tryParse(value.text));
627627
} else if (value is css.RemTerm) {

lib/style.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ class FontSize {
473473
const FontSize(this.size, {this.units = ""});
474474

475475
/// A percentage of the parent style's font size.
476-
factory FontSize.percent(int percent) {
477-
return FontSize(percent.toDouble() / -100.0, units: "%");
476+
factory FontSize.percent(double percent) {
477+
return FontSize(percent / -100.0, units: "%");
478478
}
479479

480480
factory FontSize.em(double? em) {

0 commit comments

Comments
 (0)