From 14dcbb2d84b1298d2019cad98911a06f30ae4f2e Mon Sep 17 00:00:00 2001 From: Jimmy Wei <46089773+iJimmyWei@users.noreply.github.com> Date: Fri, 17 Jul 2020 22:21:03 +0100 Subject: [PATCH] Fix overflow issue caused by a long title/subtitle for the vertical stepper (#61623) --- .../flutter/lib/src/material/stepper.dart | 8 +-- .../flutter/test/material/stepper_test.dart | 53 +++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index 01dc6825f2..1ee3d63231 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -520,9 +520,11 @@ class _StepperState extends State with TickerProviderStateMixin { _buildLine(!_isLast(index)), ], ), - Container( - margin: const EdgeInsetsDirectional.only(start: 12.0), - child: _buildHeaderText(index), + Expanded( + child: Container( + margin: const EdgeInsetsDirectional.only(start: 12.0), + child: _buildHeaderText(index), + ) ), ], ), diff --git a/packages/flutter/test/material/stepper_test.dart b/packages/flutter/test/material/stepper_test.dart index 3fc59dc468..fe3ee2a7ee 100644 --- a/packages/flutter/test/material/stepper_test.dart +++ b/packages/flutter/test/material/stepper_test.dart @@ -663,4 +663,57 @@ void main() { await tester.pump(); expect(disabledNode.hasPrimaryFocus, isFalse); }); + + testWidgets('Stepper header title should not overflow', (WidgetTester tester) async { + const String longText = + 'A long long long long long long long long long long long long text'; + + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: [ + Stepper( + steps: const [ + Step( + title: Text(longText), + content: Text('Text content') + ), + ], + ), + ], + ), + ), + ), + ); + + expect(tester.takeException(), isNull); + }); + + testWidgets('Stepper header subtitle should not overflow', (WidgetTester tester) async { + const String longText = + 'A long long long long long long long long long long long long text'; + + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: [ + Stepper( + steps: const [ + Step( + title: Text('Regular title'), + subtitle: Text(longText), + content: Text('Text content') + ), + ], + ), + ], + ), + ), + ), + ); + + expect(tester.takeException(), isNull); + }); }