@@ -301,4 +301,47 @@ Future<void> testMain() async {
301301 expect (boxes2.isNotEmpty && boxes2.length == 1 , true );
302302 expect (boxes1.first.toRect ().bottom >= boxes2.first.toRect ().top, true );
303303 });
304+
305+ test ('layout with kTextHeightNone disables parent height multiplier' , () {
306+ // Pushing a child TextStyle with kTextHeightNone overrides the parent ParagraphStyle's
307+ // height multiplier (3.0) and lays out the line at its unscaled font height.
308+ final builderWithNone = ui.ParagraphBuilder (
309+ ui.ParagraphStyle (fontFamily: 'Arial' , fontSize: 20 , height: 3.0 ),
310+ );
311+ builderWithNone.pushStyle (ui.TextStyle (height: ui.kTextHeightNone));
312+ builderWithNone.addText ('Hello' );
313+ final ui.Paragraph paragraphWithNone = builderWithNone.build ()
314+ ..layout (const ui.ParagraphConstraints (width: 500 ));
315+
316+ final builderDefault = ui.ParagraphBuilder (
317+ ui.ParagraphStyle (fontFamily: 'Arial' , fontSize: 20 ),
318+ );
319+ builderDefault.addText ('Hello' );
320+ final ui.Paragraph paragraphDefault = builderDefault.build ()
321+ ..layout (const ui.ParagraphConstraints (width: 500 ));
322+
323+ expect (paragraphWithNone.height, greaterThan (0 ));
324+ expect (paragraphWithNone.height, paragraphDefault.height);
325+ });
326+
327+ test ('layout with ParagraphStyle(kTextHeightNone)' , () {
328+ // Passing kTextHeightNone directly on ParagraphStyle produces the same unscaled
329+ // line height as omitting height (null), rather than multiplying by 0.0.
330+ final builderWithNone = ui.ParagraphBuilder (
331+ ui.ParagraphStyle (fontFamily: 'Arial' , fontSize: 20 , height: ui.kTextHeightNone),
332+ );
333+ builderWithNone.addText ('Hello' );
334+ final ui.Paragraph paragraphWithNone = builderWithNone.build ()
335+ ..layout (const ui.ParagraphConstraints (width: 500 ));
336+
337+ final builderDefault = ui.ParagraphBuilder (
338+ ui.ParagraphStyle (fontFamily: 'Arial' , fontSize: 20 ),
339+ );
340+ builderDefault.addText ('Hello' );
341+ final ui.Paragraph paragraphDefault = builderDefault.build ()
342+ ..layout (const ui.ParagraphConstraints (width: 500 ));
343+
344+ expect (paragraphWithNone.height, greaterThan (0 ));
345+ expect (paragraphWithNone.height, paragraphDefault.height);
346+ });
304347}
0 commit comments