From 55044a605fed74532d0f709fa437acc2adcc24dd Mon Sep 17 00:00:00 2001 From: Tomasz Gucio <72562119+tgucio@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:28:07 +0200 Subject: [PATCH] Constrain _RenderScaledInlineWidget child size in computeDryLayout (#131765) --- packages/flutter/lib/src/widgets/widget_span.dart | 2 +- packages/flutter/test/widgets/text_test.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/flutter/lib/src/widgets/widget_span.dart b/packages/flutter/lib/src/widgets/widget_span.dart index 65427e7ed2d..242cb3033c4 100644 --- a/packages/flutter/lib/src/widgets/widget_span.dart +++ b/packages/flutter/lib/src/widgets/widget_span.dart @@ -385,7 +385,7 @@ class _RenderScaledInlineWidget extends RenderBox with RenderObjectWithChildMixi Size computeDryLayout(BoxConstraints constraints) { assert(!constraints.hasBoundedHeight); final Size unscaledSize = child?.computeDryLayout(BoxConstraints(maxWidth: constraints.maxWidth / scale)) ?? Size.zero; - return unscaledSize * scale; + return constraints.constrain(unscaledSize * scale); } @override diff --git a/packages/flutter/test/widgets/text_test.dart b/packages/flutter/test/widgets/text_test.dart index c535fbd9c52..5c2f69694c1 100644 --- a/packages/flutter/test/widgets/text_test.dart +++ b/packages/flutter/test/widgets/text_test.dart @@ -273,8 +273,8 @@ void main() { textDirection: TextDirection.ltr, child: Center( child: SizedBox( - width: 100.3, - child: Text.rich(WidgetSpan(child: Row()), textScaleFactor: 0.3), + width: 502.5454545454545, + child: Text.rich(WidgetSpan(child: Row()), textScaleFactor: 0.95), ), ), ),