@@ -1217,12 +1217,36 @@ void main() {
1217
1217
textDirection: TextDirection .ltr,
1218
1218
);
1219
1219
1220
- textPainter.layout ();
1221
- expect (
1222
- textPainter.getWordBoundary (const TextPosition (offset: 8 )),
1223
- const TextRange (start: 8 , end: 16 ),
1220
+ textPainter.layout ();
1221
+ expect (
1222
+ textPainter.getWordBoundary (const TextPosition (offset: 8 )),
1223
+ const TextRange (start: 8 , end: 16 ),
1224
+ );
1225
+ }, skip: isBrowser); // https://github.com/flutter/flutter/issues/61017
1226
+
1227
+ test ('TextHeightBehavior with strut on empty paragraph' , () {
1228
+ // Regression test for https://github.com/flutter/flutter/issues/112123
1229
+ const TextStyle style = TextStyle (height: 11 , fontSize: 7 );
1230
+ const TextSpan simple = TextSpan (text: 'x' , style: style);
1231
+ const TextSpan emptyString = TextSpan (text: '' , style: style);
1232
+ const TextSpan emptyParagraph = TextSpan (style: style);
1233
+
1234
+ final TextPainter painter = TextPainter (
1235
+ textDirection: TextDirection .ltr,
1236
+ strutStyle: StrutStyle .fromTextStyle (style, forceStrutHeight: true ),
1237
+ textHeightBehavior: const TextHeightBehavior (applyHeightToFirstAscent: false , applyHeightToLastDescent: false ),
1224
1238
);
1225
- }, skip: isBrowser); // https://github.com/flutter/flutter/issues/61017
1239
+
1240
+ painter.text = simple;
1241
+ painter.layout ();
1242
+ final double height = painter.height;
1243
+ for (final TextSpan span in < TextSpan > [simple, emptyString, emptyParagraph]) {
1244
+ painter.text = span;
1245
+ painter.layout ();
1246
+ expect (painter.height, height, reason: '$span is expected to have a height of $height ' );
1247
+ expect (painter.preferredLineHeight, height, reason: '$span is expected to have a height of $height ' );
1248
+ }
1249
+ });
1226
1250
1227
1251
test ('TextPainter plainText getter' , () {
1228
1252
final TextPainter painter = TextPainter ()
0 commit comments