@@ -59,8 +59,19 @@ class MarkdownStyleSheet {
5959 this .orderedListAlign = WrapAlignment .start,
6060 this .blockquoteAlign = WrapAlignment .start,
6161 this .codeblockAlign = WrapAlignment .start,
62- this .textScaleFactor,
63- }) : _styles = < String , TextStyle ? > {
62+ @Deprecated ('Use textScaler instead.' ) this .textScaleFactor,
63+ TextScaler ? textScaler,
64+ }) : assert (
65+ textScaler == null || textScaleFactor == null ,
66+ 'textScaleFactor is deprecated and cannot be specified when textScaler is specified.' ,
67+ ),
68+ textScaler = textScaler ??
69+ // Internally, only textScaler is used, so convert the scale factor
70+ // to a linear scaler.
71+ (textScaleFactor == null
72+ ? null
73+ : TextScaler .linear (textScaleFactor)),
74+ _styles = < String , TextStyle ? > {
6475 'a' : a,
6576 'p' : p,
6677 'li' : p,
@@ -380,8 +391,19 @@ class MarkdownStyleSheet {
380391 WrapAlignment ? orderedListAlign,
381392 WrapAlignment ? blockquoteAlign,
382393 WrapAlignment ? codeblockAlign,
383- double ? textScaleFactor,
394+ @Deprecated ('Use textScaler instead.' ) double ? textScaleFactor,
395+ TextScaler ? textScaler,
384396 }) {
397+ assert (
398+ textScaler == null || textScaleFactor == null ,
399+ 'textScaleFactor is deprecated and cannot be specified when textScaler is specified.' ,
400+ );
401+ // If either of textScaler or textScaleFactor is non-null, pass null for the
402+ // other instead of the previous value, since only one is allowed.
403+ final TextScaler ? newTextScaler =
404+ textScaler ?? (textScaleFactor == null ? this .textScaler : null );
405+ final double ? nextTextScaleFactor =
406+ textScaleFactor ?? (textScaler == null ? this .textScaleFactor : null );
385407 return MarkdownStyleSheet (
386408 a: a ?? this .a,
387409 p: p ?? this .p,
@@ -435,7 +457,8 @@ class MarkdownStyleSheet {
435457 orderedListAlign: orderedListAlign ?? this .orderedListAlign,
436458 blockquoteAlign: blockquoteAlign ?? this .blockquoteAlign,
437459 codeblockAlign: codeblockAlign ?? this .codeblockAlign,
438- textScaleFactor: textScaleFactor ?? this .textScaleFactor,
460+ textScaler: newTextScaler,
461+ textScaleFactor: nextTextScaleFactor,
439462 );
440463 }
441464
@@ -497,6 +520,11 @@ class MarkdownStyleSheet {
497520 blockquoteAlign: other.blockquoteAlign,
498521 codeblockAlign: other.codeblockAlign,
499522 textScaleFactor: other.textScaleFactor,
523+ // Only one of textScaler and textScaleFactor can be passed. If
524+ // other.textScaleFactor is non-null, then the sheet was created with a
525+ // textScaleFactor and the textScaler was derived from that, so should be
526+ // ignored so that the textScaleFactor continues to be set.
527+ textScaler: other.textScaleFactor == null ? other.textScaler : null ,
500528 );
501529 }
502530
@@ -650,7 +678,14 @@ class MarkdownStyleSheet {
650678 /// The [WrapAlignment] to use for a code block. Defaults to start.
651679 final WrapAlignment codeblockAlign;
652680
653- /// The text scale factor to use in textual elements
681+ /// The text scaler to use in textual elements.
682+ final TextScaler ? textScaler;
683+
684+ /// The text scale factor to use in textual elements.
685+ ///
686+ /// This will be non-null only if the sheet was created with the deprecated
687+ /// [textScaleFactor] instead of [textScaler] .
688+ @Deprecated ('Use textScaler instead.' )
654689 final double ? textScaleFactor;
655690
656691 /// A [Map] from element name to the corresponding [TextStyle] object.
@@ -717,7 +752,7 @@ class MarkdownStyleSheet {
717752 other.orderedListAlign == orderedListAlign &&
718753 other.blockquoteAlign == blockquoteAlign &&
719754 other.codeblockAlign == codeblockAlign &&
720- other.textScaleFactor == textScaleFactor ;
755+ other.textScaler == textScaler ;
721756 }
722757
723758 @override
@@ -774,6 +809,7 @@ class MarkdownStyleSheet {
774809 orderedListAlign,
775810 blockquoteAlign,
776811 codeblockAlign,
812+ textScaler,
777813 textScaleFactor,
778814 ]);
779815 }
0 commit comments