@@ -106,6 +106,10 @@ class ControlsDetails {
106
106
/// * [WidgetBuilder] , which is similar but only takes a [BuildContext] .
107
107
typedef ControlsWidgetBuilder = Widget Function (BuildContext context, ControlsDetails details);
108
108
109
+ /// A builder that creates the icon widget for the [Step] at [stepIndex] , given
110
+ /// [stepState] .
111
+ typedef StepIconBuilder = Widget ? Function (int stepIndex, StepState stepState);
112
+
109
113
const TextStyle _kStepStyle = TextStyle (
110
114
fontSize: 12.0 ,
111
115
color: Colors .white,
@@ -207,6 +211,7 @@ class Stepper extends StatefulWidget {
207
211
this .controlsBuilder,
208
212
this .elevation,
209
213
this .margin,
214
+ this .stepIconBuilder,
210
215
}) : assert (0 <= currentStep && currentStep < steps.length);
211
216
212
217
/// The steps of the stepper whose titles, subtitles, icons always get shown.
@@ -303,9 +308,17 @@ class Stepper extends StatefulWidget {
303
308
/// The elevation of this stepper's [Material] when [type] is [StepperType.horizontal] .
304
309
final double ? elevation;
305
310
306
- /// custom margin on vertical stepper.
311
+ /// Custom margin on vertical stepper.
307
312
final EdgeInsetsGeometry ? margin;
308
313
314
+ /// Callback for creating custom icons for the [steps] .
315
+ ///
316
+ /// When overriding icon for [StepState.error] , please return
317
+ /// a widget whose width and height are 14 pixels or less to avoid overflow.
318
+ ///
319
+ /// If null, the default icons will be used for respective [StepState] .
320
+ final StepIconBuilder ? stepIconBuilder;
321
+
309
322
@override
310
323
State <Stepper > createState () => _StepperState ();
311
324
}
@@ -373,6 +386,10 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
373
386
Widget _buildCircleChild (int index, bool oldState) {
374
387
final StepState state = oldState ? _oldStates[index]! : widget.steps[index].state;
375
388
final bool isDarkActive = _isDark () && widget.steps[index].isActive;
389
+ final Widget ? icon = widget.stepIconBuilder? .call (index, state);
390
+ if (icon != null ) {
391
+ return icon;
392
+ }
376
393
switch (state) {
377
394
case StepState .indexed:
378
395
case StepState .disabled:
0 commit comments