diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index e1071a1a986..4b3f3a604e1 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -791,7 +791,7 @@ class _StepperState extends State with TickerProviderStateMixin { width: _stepIconWidth ?? _kStepSize, child: Center( child: SizedBox( - width: widget.connectorThickness ?? 1.0, + width: !_isLast(index) ? (widget.connectorThickness ?? 1.0) : 0.0, child: Container( color: _connectorColor(widget.steps[index].isActive), ), diff --git a/packages/flutter/test/material/stepper_test.dart b/packages/flutter/test/material/stepper_test.dart index e21bc6fb4cd..5b2349e082a 100644 --- a/packages/flutter/test/material/stepper_test.dart +++ b/packages/flutter/test/material/stepper_test.dart @@ -1689,6 +1689,37 @@ testWidgets('Stepper custom indexed controls test', (WidgetTester tester) async expect(mergedStyle.gradient, stepStyle.gradient); expect(mergedStyle.indexStyle, stepStyle.indexStyle); }); + + // This is a regression test for https://github.com/flutter/flutter/issues/144376. + testWidgets('Vertical Stepper does not draw connector on the last step', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Center( + child: Stepper( + currentStep: 1, + steps: const [ + Step( + title: Text('step1'), + content: Text('step1 content'), + ), + Step( + title: Text('step2'), + content: Text('step2 content'), + ), + ], + ), + ), + ), + ) + ); + + final SizedBox lastConnector = tester.widget( + find.descendant(of: find.byType(PositionedDirectional), + matching: find.byType(SizedBox).last, + )); + expect(lastConnector.width, equals(0.0)); + }); } class _TappableColorWidget extends StatefulWidget {