@@ -291,7 +291,11 @@ class Style {
291291 direction: child.direction ?? direction,
292292 fontFamily: child.fontFamily ?? fontFamily,
293293 fontFeatureSettings: child.fontFeatureSettings ?? fontFeatureSettings,
294- fontSize: child.fontSize ?? fontSize,
294+ fontSize: child.fontSize != null ?
295+ fontSize != null && child.fontSize? .units == "em" ?
296+ FontSize (child.fontSize.size * fontSize.size, "" ) : child.fontSize
297+ : fontSize != null && fontSize.size < 0 ?
298+ FontSize .percent (100 ) : fontSize,
295299 fontStyle: child.fontStyle ?? fontStyle,
296300 fontWeight: child.fontWeight ?? fontWeight,
297301 letterSpacing: child.letterSpacing ?? letterSpacing,
@@ -382,7 +386,7 @@ class Style {
382386 this .textDecorationThickness = textStyle.decorationThickness;
383387 this .fontFamily = textStyle.fontFamily;
384388 this .fontFeatureSettings = textStyle.fontFeatures;
385- this .fontSize = FontSize (textStyle.fontSize);
389+ this .fontSize = FontSize (textStyle.fontSize, "" );
386390 this .fontStyle = textStyle.fontStyle;
387391 this .fontWeight = textStyle.fontWeight;
388392 this .letterSpacing = textStyle.letterSpacing;
@@ -401,16 +405,22 @@ enum Display {
401405
402406class FontSize {
403407 final double size;
408+ final String units;
404409
405- const FontSize (this .size);
410+ const FontSize (this .size, this .units );
406411
407412 /// A percentage of the parent style's font size.
408413 factory FontSize .percent (int percent) {
409- return FontSize (percent.toDouble () / - 100.0 );
414+ return FontSize (percent.toDouble () / - 100.0 , "%" );
410415 }
411416
412- factory FontSize .em (int em) {
413- return FontSize (em.toDouble () * 16 - 2 );
417+ factory FontSize .em (double em) {
418+ return FontSize (em, "em" );
419+ }
420+
421+ factory FontSize .rem (double rem) {
422+ print (rem * 16 - 2 );
423+ return FontSize (rem * 16 - 2 , "rem" );
414424 }
415425 // These values are calculated based off of the default (`medium`)
416426 // being 14px.
@@ -419,15 +429,15 @@ class FontSize {
419429 //
420430 // Negative values are computed during parsing to be a percentage of
421431 // the parent style's font size.
422- static const xxSmall = FontSize (7.875 );
423- static const xSmall = FontSize (8.75 );
424- static const small = FontSize (11.375 );
425- static const medium = FontSize (14.0 );
426- static const large = FontSize (15.75 );
427- static const xLarge = FontSize (21.0 );
428- static const xxLarge = FontSize (28.0 );
429- static const smaller = FontSize (- 0.83 );
430- static const larger = FontSize (- 1.2 );
432+ static const xxSmall = FontSize (7.875 , "" );
433+ static const xSmall = FontSize (8.75 , "" );
434+ static const small = FontSize (11.375 , "" );
435+ static const medium = FontSize (14.0 , "" );
436+ static const large = FontSize (15.75 , "" );
437+ static const xLarge = FontSize (21.0 , "" );
438+ static const xxLarge = FontSize (28.0 , "" );
439+ static const smaller = FontSize (- 0.83 , "" );
440+ static const larger = FontSize (- 1.2 , "" );
431441}
432442
433443enum ListStyleType {
0 commit comments