diff --git a/packages/flutter/lib/src/widgets/widget_span.dart b/packages/flutter/lib/src/widgets/widget_span.dart index b0e5ad99b3..776d4087ce 100644 --- a/packages/flutter/lib/src/widgets/widget_span.dart +++ b/packages/flutter/lib/src/widgets/widget_span.dart @@ -375,7 +375,7 @@ class _RenderScaledInlineWidget extends RenderBox with RenderObjectWithChildMixi // Only constrain the width to the maximum width of the paragraph. // Leave height unconstrained, which will overflow if expanded past. child.layout(BoxConstraints(maxWidth: constraints.maxWidth / scale), parentUsesSize: true); - size = child.size * scale; + size = constraints.constrain(child.size * scale); } @override diff --git a/packages/flutter/test/widgets/text_test.dart b/packages/flutter/test/widgets/text_test.dart index ea3202509c..0289a64d20 100644 --- a/packages/flutter/test/widgets/text_test.dart +++ b/packages/flutter/test/widgets/text_test.dart @@ -266,6 +266,23 @@ void main() { expect(renderText.size.height, singleLineHeight * textScaleFactor * 3); }); + testWidgets("Inline widgets' scaled sizes are constrained", (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/130588 + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: SizedBox( + width: 100.3, + child: Text.rich(WidgetSpan(child: Row()), textScaleFactor: 0.3), + ), + ), + ), + ); + + expect(tester.takeException(), isNull); + }); + testWidgets('semanticsLabel can override text label', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget(