Elevation for Stepper(horizontally) (#83177)
This commit is contained in:
committed by
GitHub
parent
ec5cfc001d
commit
fdc3fb3f9e
@@ -185,6 +185,7 @@ class Stepper extends StatefulWidget {
|
||||
this.onStepContinue,
|
||||
this.onStepCancel,
|
||||
this.controlsBuilder,
|
||||
this.elevation,
|
||||
}) : assert(steps != null),
|
||||
assert(type != null),
|
||||
assert(currentStep != null),
|
||||
@@ -280,6 +281,9 @@ class Stepper extends StatefulWidget {
|
||||
/// {@end-tool}
|
||||
final ControlsWidgetBuilder? controlsBuilder;
|
||||
|
||||
/// The elevation of this stepper's [Material] when [type] is [StepperType.horizontal].
|
||||
final double? elevation;
|
||||
|
||||
@override
|
||||
State<Stepper> createState() => _StepperState();
|
||||
}
|
||||
@@ -697,7 +701,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Material(
|
||||
elevation: 2.0,
|
||||
elevation: widget.elevation ?? 2,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
child: Row(
|
||||
|
||||
@@ -887,4 +887,70 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(circleFillColor(), dark.background);
|
||||
});
|
||||
|
||||
testWidgets('Stepper custom elevation', (WidgetTester tester) async {
|
||||
const double elevation = 4.0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
child: SizedBox(
|
||||
width: 200,
|
||||
height: 75,
|
||||
child: Stepper(
|
||||
type: StepperType.horizontal,
|
||||
elevation: elevation,
|
||||
steps: const <Step>[
|
||||
Step(
|
||||
title: Text('Regular title'),
|
||||
content: Text('Text content'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final Material material = tester.firstWidget<Material>(
|
||||
find.descendant(
|
||||
of: find.byType(Stepper),
|
||||
matching: find.byType(Material),
|
||||
),
|
||||
);
|
||||
|
||||
expect(material.elevation, elevation);
|
||||
});
|
||||
|
||||
testWidgets('Stepper with default elevation', (WidgetTester tester) async {
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
child: SizedBox(
|
||||
width: 200,
|
||||
height: 75,
|
||||
child: Stepper(
|
||||
type: StepperType.horizontal,
|
||||
steps: const <Step>[
|
||||
Step(
|
||||
title: Text('Regular title'),
|
||||
content: Text('Text content')
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final Material material = tester.firstWidget<Material>(
|
||||
find.descendant(
|
||||
of: find.byType(Stepper),
|
||||
matching: find.byType(Material),
|
||||
),
|
||||
);
|
||||
|
||||
expect(material.elevation, 2.0);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user