我正在关注本教程https://www.youtube.com/watch?v=izbkS2svuq4
并且简要提到了将 StepState 修改为 StepState.editing 以便您获得一个铅笔图标。
如何修改我正在执行的步骤的 StepState,以便在我踩到/越过它时将状态更改为正在编辑(或完成)
class _SimpleWidgetState extends State<SimpleWidget> {
int _stepCounter = 0;
List<Step> steps = [
Step(
title: Text("Step One"),
content: Text("This is the first step"),
isActive: true
),
Step(
title: Text("Step Two"),
content: Text("This is the second step"),
isActive: true,
),
Step(
title: Text("Step Three"),
content: Text("This is the third step"),
isActive: true,
),
Step(
title: Text("Step Four"),
content: Text("This is the fourth step"),
isActive: true,
),
];
@override
Widget build(BuildContext context) {
return Container(
child: Stepper(
steps: steps,
currentStep: this._stepCounter,
type: StepperType.vertical,
onStepTapped: (step) {
setState(() {
_stepCounter = step;
steps[step].state = StepState.editing; // this does not work but is what Im trying to accomplish
});
},
onStepCancel: () {
setState(() {
_stepCounter > 0 ? _stepCounter -= 1 : _stepCounter = 0;
});
},
onStepContinue: () {
setState(() {
_stepCounter < steps.length - 1 ? _stepCounter += 1 : _stepCounter = 0;
});
},
),
);
}
}