`_RenderScaledInlineWidget` constrains child size (#130648)
Fixes https://github.com/flutter/flutter/issues/130588
diff --git a/packages/flutter/lib/src/widgets/widget_span.dart b/packages/flutter/lib/src/widgets/widget_span.dart
index b0e5ad9..776d408 100644
--- a/packages/flutter/lib/src/widgets/widget_span.dart
+++ b/packages/flutter/lib/src/widgets/widget_span.dart
@@ -375,7 +375,7 @@
// 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 ea32025..0289a64 100644
--- a/packages/flutter/test/widgets/text_test.dart
+++ b/packages/flutter/test/widgets/text_test.dart
@@ -266,6 +266,23 @@
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(