From 69c426cb639835ff9c3c72ea0104998f68770ab3 Mon Sep 17 00:00:00 2001 From: "salim.azeri" Date: Thu, 1 Sep 2022 00:24:07 +0200 Subject: [PATCH 1/2] Add TextHeightBehavior support --- lib/src/auto_size_text.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/src/auto_size_text.dart b/lib/src/auto_size_text.dart index ec43838..5b23924 100644 --- a/lib/src/auto_size_text.dart +++ b/lib/src/auto_size_text.dart @@ -32,6 +32,7 @@ class AutoSizeText extends StatefulWidget { this.textScaleFactor, this.maxLines, this.semanticsLabel, + this.textHeightBehavior, }) : textSpan = null, super(key: key); @@ -57,6 +58,7 @@ class AutoSizeText extends StatefulWidget { this.textScaleFactor, this.maxLines, this.semanticsLabel, + this.textHeightBehavior, }) : data = null, super(key: key); @@ -215,6 +217,19 @@ class AutoSizeText extends StatefulWidget { /// ``` final String? semanticsLabel; + /// Defines how to apply [TextStyle.height] over and under text. + /// + /// [TextHeightBehavior.applyHeightToFirstAscent] and + /// [TextHeightBehavior.applyHeightToLastDescent] represent whether the + /// [TextStyle.height] modifier will be applied to the corresponding metric. By + /// default both properties are true, and [TextStyle.height] is applied as + /// normal. When set to false, the font's default ascent will be used. + /// + /// [TextHeightBehavior.leadingDistribution] determines how the + /// leading is distributed over and under text. This + /// property applies before [TextHeightBehavior.applyHeightToFirstAscent] and + final TextHeightBehavior? textHeightBehavior; + @override _AutoSizeTextState createState() => _AutoSizeTextState(); } @@ -425,6 +440,7 @@ class _AutoSizeTextState extends State { textScaleFactor: 1, maxLines: maxLines, semanticsLabel: widget.semanticsLabel, + textHeightBehavior: widget.textHeightBehavior, ); } else { return Text.rich( @@ -440,6 +456,7 @@ class _AutoSizeTextState extends State { textScaleFactor: fontSize / style.fontSize!, maxLines: maxLines, semanticsLabel: widget.semanticsLabel, + textHeightBehavior: widget.textHeightBehavior, ); } } From 3ac19abec4e2bc6724b41e2d2d6f89a5ef187780 Mon Sep 17 00:00:00 2001 From: Salim Azeri <63226162+salimazeriDev@users.noreply.github.com> Date: Thu, 1 Sep 2022 23:13:38 +0200 Subject: [PATCH 2/2] fix documentation --- lib/src/auto_size_text.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/auto_size_text.dart b/lib/src/auto_size_text.dart index 5b23924..f1aaaae 100644 --- a/lib/src/auto_size_text.dart +++ b/lib/src/auto_size_text.dart @@ -228,6 +228,7 @@ class AutoSizeText extends StatefulWidget { /// [TextHeightBehavior.leadingDistribution] determines how the /// leading is distributed over and under text. This /// property applies before [TextHeightBehavior.applyHeightToFirstAscent] and + /// [TextHeightBehavior.applyHeightToLastDescent]. final TextHeightBehavior? textHeightBehavior; @override