1.Stepper相关属性
名字 | 注解 |
currentStep | 当前选中的步骤 |
onStepTapped | 选中步骤的回调方法 |
onStepContinue | 单击下一步的回调方法 |
onStepCancel | 单击上一步的回调方法 |
steps(数组) | 存在 Step组件 |
2.代码示例
Container(
child: Stepper(
currentStep: _currentStep,
onStepTapped: (index) {
setState(() {
_currentStep = index;
});
},
//下一步
onStepContinue: () {
setState(() {
_currentStep < 2 ? _currentStep += 1 : _currentStep = 0;
});
},
//上一步
onStepCancel: (){
setState(() {
_currentStep >0 ? _currentStep -= 1 : _currentStep = 0;
});
},
steps: [
Step(
title: Text("第一步"),
subtitle: Text("我是一个副标题"),
content: Text("第一部的具体你内容"),
isActive: _currentStep == 0, //是否选中
),
Step(
title: Text("第二步"),
content: Text("第二部的具体你内容"),
isActive: _currentStep == 1, //是否选中
),
Step(
title: Text("第三步"),
content: Text("第三部的具体你内容"),
isActive: _currentStep == 2, //是否选中
),
]),
);