diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index d862bade9f..9f932321f8 100755 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -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 createState() => _StepperState(); } @@ -697,7 +701,7 @@ class _StepperState extends State with TickerProviderStateMixin { return Column( children: [ Material( - elevation: 2.0, + elevation: widget.elevation ?? 2, child: Container( margin: const EdgeInsets.symmetric(horizontal: 24.0), child: Row( diff --git a/packages/flutter/test/material/stepper_test.dart b/packages/flutter/test/material/stepper_test.dart index 4fc7236fcb..8c0d537f4f 100644 --- a/packages/flutter/test/material/stepper_test.dart +++ b/packages/flutter/test/material/stepper_test.dart @@ -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( + title: Text('Regular title'), + content: Text('Text content'), + ), + ], + ), + ), + ), + ), + ); + + final Material material = tester.firstWidget( + 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( + title: Text('Regular title'), + content: Text('Text content') + ), + ], + ), + ), + ), + ), + ); + + final Material material = tester.firstWidget( + find.descendant( + of: find.byType(Stepper), + matching: find.byType(Material), + ), + ); + + expect(material.elevation, 2.0); + }); }