Can you tell me what's wrong in my code?
Widget _createProfileStepper() {
int currentStep = 0;
List<Step> createAccSteps = [
new Step(
title: Container(),
content: new Text('This is the first step.'),
isActive: currentStep >= 0,
state: currentStep >= 0 ? StepState.editing : StepState.disabled,
),
new Step(
title: Container(),
content: new Text('This is the second step.'),
isActive: currentStep >= 0,
state: currentStep >= 1 ? StepState.editing : StepState.disabled,
),
new Step(
title: Container(),
content: new Text('This is the third step.'),
isActive: currentStep >= 0,
state: currentStep >= 2 ? StepState.editing : StepState.disabled,
),
new Step(
title: Container(),
content: new Text('This is the second step.'),
isActive: currentStep >= 0,
state: currentStep >= 3 ? StepState.editing : StepState.disabled,
),
new Step(
title: Container(),
content: new Text('This is the third step.'),
isActive: currentStep >= 0,
state: currentStep >= 4 ? StepState.editing : StepState.disabled,
),
];
return Scaffold(
appBar: AppBar(
title: Text("Create Profile"),
),
body: Stepper(
type: StepperType.horizontal,
currentStep: currentStep,
onStepTapped: (step) {
setState(() {
currentStep = step;
});
},
onStepContinue: () {
setState(() {
if (currentStep < createAccSteps.length - 1) {
currentStep = currentStep + 1;
} else {}
});
},
onStepCancel: () {
setState(() {
if(currentStep > 0){
currentStep = currentStep - 1;
}
else {
currentStep = 0;
}
});
},
steps: createAccSteps,
),
);
}
I followed all examples for Flutter's stepper but still no luck. I can tap the continue button but it is not moving to another step. Did I forget something? I created a Stateful Widget class then a button would take me to call this _createProfileStepper(). Thanks.