add margin to vertical stepper (#86067)

* add marging to vertical stepper

* Remove tralling spaces

* Update docstring
This commit is contained in:
Abhishek Ghaskata 2021-08-24 00:32:02 +05:30 committed by GitHub
parent 1a5692b722
commit 49bf933b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View File

@ -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<Stepper> createState() => _StepperState();
}
@ -611,7 +615,7 @@ class _StepperState extends State<Stepper> 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,

View File

@ -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>[
Step(
title: Text('Regular title'),
content: Text('Text content')
),
],
),
),
),
),
);
final Stepper material = tester.firstWidget<Stepper>(
find.descendant(
of: find.byType(Material),
matching: find.byType(Stepper),
),
);
expect(material.margin, equals(margin));
});
}