diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index b0aab18929..29fa2422ea 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -135,6 +135,7 @@ class Stepper extends StatefulWidget { Stepper({ Key key, @required this.steps, + this.physics, this.type = StepperType.vertical, this.currentStep = 0, this.onStepTapped, @@ -152,6 +153,15 @@ class Stepper extends StatefulWidget { /// The length of [steps] must not change. final List steps; + /// How the stepper's scroll view should respond to user input. + /// + /// For example, determines how the scroll view continues to + /// animate after the user stops dragging the scroll view. + /// + /// If the stepper is contained within another scrollable it + /// can be helpful to set this property to [ClampingScrollPhysics]. + final ScrollPhysics physics; + /// The type of stepper that determines the layout. In the case of /// [StepperType.horizontal], the content of the current step is displayed /// underneath as opposed to the [StepperType.vertical] case where it is @@ -594,6 +604,7 @@ class _StepperState extends State with TickerProviderStateMixin { return ListView( shrinkWrap: true, + physics: widget.physics, children: children, ); } diff --git a/packages/flutter/test/material/stepper_test.dart b/packages/flutter/test/material/stepper_test.dart index 24eeeea242..81e9ca7fc6 100644 --- a/packages/flutter/test/material/stepper_test.dart +++ b/packages/flutter/test/material/stepper_test.dart @@ -507,4 +507,37 @@ void main() { renderObject = tester.renderObject(find.byIcon(Icons.check)); expect(renderObject.size, equals(const Size.square(18.0))); }); + + testWidgets('Stepper physics scroll error test', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: [ + Stepper( + steps: const [ + Step(title: Text('Step 1'), content: Text('Text 1')), + Step(title: Text('Step 2'), content: Text('Text 2')), + Step(title: Text('Step 3'), content: Text('Text 3')), + Step(title: Text('Step 4'), content: Text('Text 4')), + Step(title: Text('Step 5'), content: Text('Text 5')), + Step(title: Text('Step 6'), content: Text('Text 6')), + Step(title: Text('Step 7'), content: Text('Text 7')), + Step(title: Text('Step 8'), content: Text('Text 8')), + Step(title: Text('Step 9'), content: Text('Text 9')), + Step(title: Text('Step 10'), content: Text('Text 10')), + ], + ), + const Text('Text After Stepper'), + ], + ), + ), + ), + ); + + await tester.fling(find.byType(Stepper), const Offset(0.0, -100.0), 1000.0); + await tester.pumpAndSettle(); + + expect(find.text('Text After Stepper'), findsNothing); + }); }