mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
add margin to vertical stepper (#86067)
* add marging to vertical stepper * Remove tralling spaces * Update docstring
This commit is contained in:
parent
1a5692b722
commit
49bf933b59
@ -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,
|
||||
|
||||
@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user