From 49bf933b5952e77864ade2b1c0a43ce08d49335e Mon Sep 17 00:00:00 2001 From: Abhishek Ghaskata Date: Tue, 24 Aug 2021 00:32:02 +0530 Subject: [PATCH] add margin to vertical stepper (#86067) * add marging to vertical stepper * Remove tralling spaces * Update docstring --- .../flutter/lib/src/material/stepper.dart | 6 ++- .../flutter/test/material/stepper_test.dart | 38 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index 9f932321f8b..2c0644cdf9b 100755 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -186,6 +186,7 @@ class Stepper extends StatefulWidget { this.onStepCancel, this.controlsBuilder, this.elevation, + this.margin, }) : assert(steps != null), assert(type != null), assert(currentStep != null), @@ -284,6 +285,9 @@ class Stepper extends StatefulWidget { /// The elevation of this stepper's [Material] when [type] is [StepperType.horizontal]. final double? elevation; + /// custom margin on vertical stepper. + final EdgeInsetsGeometry? margin; + @override State createState() => _StepperState(); } @@ -611,7 +615,7 @@ class _StepperState extends State with TickerProviderStateMixin { AnimatedCrossFade( firstChild: Container(height: 0.0), secondChild: Container( - margin: const EdgeInsetsDirectional.only( + margin: widget.margin ?? const EdgeInsetsDirectional.only( start: 60.0, end: 24.0, bottom: 24.0, diff --git a/packages/flutter/test/material/stepper_test.dart b/packages/flutter/test/material/stepper_test.dart index 8c0d537f4f0..05274062a6d 100644 --- a/packages/flutter/test/material/stepper_test.dart +++ b/packages/flutter/test/material/stepper_test.dart @@ -952,5 +952,43 @@ void main() { ); expect(material.elevation, 2.0); + }); + + testWidgets('Stepper custom margin', (WidgetTester tester) async { + + const EdgeInsetsGeometry margin = EdgeInsetsDirectional.only( + bottom: 20, + top: 20, + ); + + await tester.pumpWidget( + MaterialApp( + home: Material( + child: SizedBox( + width: 200, + height: 75, + child: Stepper( + margin: margin, + type: StepperType.vertical, + steps: const [ + Step( + title: Text('Regular title'), + content: Text('Text content') + ), + ], + ), + ), + ), + ), + ); + + final Stepper material = tester.firstWidget( + find.descendant( + of: find.byType(Material), + matching: find.byType(Stepper), + ), + ); + + expect(material.margin, equals(margin)); }); }