Flutter 根据步骤编号自定义步进器小部件
我的应用程序中包含了一个Stepper小部件 这里是实现:Flutter 根据步骤编号自定义步进器小部件,flutter,Flutter,我的应用程序中包含了一个Stepper小部件 这里是实现: Expanded( child: Stepper( controlsBuilder: (BuildContext context, {VoidCallback onStepContinue, VoidCallback onStepCancel}) { return Row(
Expanded(
child: Stepper(
controlsBuilder: (BuildContext context,
{VoidCallback onStepContinue, VoidCallback onStepCancel}) {
return Row(
children: <Widget>[
TextButton(
onPressed: onStepCancel,
child: Text('Previous'.tr().toString()),
),
TextButton(
onPressed: onStepContinue,
child: Text('Next'.tr().toString()),
),
],
);
},
steps: _stepper(),
physics: ClampingScrollPhysics(),
currentStep: this._currentStep,
onStepTapped: (step) {
setState(() {
this._currentStep = step;
});
},
onStepContinue: () {
setState(() {
if (this._currentStep < this._stepper().length - 1) {
this._currentStep = this._currentStep + 1;
} else {
//your code
print('complete');
}
});
},
onStepCancel: () {
setState(() {
if (this._currentStep > 0) {
this._currentStep = this._currentStep - 1;
} else {
this._currentStep = 0;
}
});
},
),
),
扩展(
孩子:步进机(
controlsBuilder:(BuildContext上下文,
{VoidCallback onStepContinue,VoidCallback onStepCancel}){
返回行(
儿童:[
文本按钮(
onPressed:onStepCancel,
子项:文本('Previous'.tr().toString()),
),
文本按钮(
onPressed:onStepContinue,
子项:文本('Next'.tr().toString()),
),
],
);
},
步骤:_stepper(),
物理:ClampingScrollPhysics(),
currentStep:此。\ u currentStep,
步骤:(步骤){
设置状态(){
这是。_currentStep=步骤;
});
},
onStepContinue:(){
设置状态(){
if(this.\u currentStep0){
此._currentStep=此._currentStep-1;
}否则{
这一点。_currentStep=0;
}
});
},
),
),
我包括了6个步骤
现在,在每一步上,都会为方法onStepCancel和onStepContinue显示两个文本按钮,但我想在步骤1中隐藏onStepCancel的文本按钮,并在步骤6中隐藏onStepContinue的文本按钮
如何实现这两个条件