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); + }); }