class StepperDemo extends StatefulWidget {
@override
_StepperDemoState createState() => _StepperDemoState();
}
class _StepperDemoState extends State<StepperDemo> {
int _currentStep = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('StepperDemo'), elevation: 0.0,),
body: Container(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(primaryColor: Colors.blue),
child: Stepper(
currentStep: _currentStep,
onStepTapped: (int value) { // 点击步骤的序号触发的方法
setState(() {
_currentStep = value;
});
},
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('待付款'), subtitle: Text('待付款'),content: Text('您的订单尚未支付'), isActive: _currentStep == 1),
Step(title: Text('待收货'), subtitle: Text('待收获'),content: Text('您的包裹正在运输中'), isActive: _currentStep == 2),
]
),
),
],
),
),
);
}
}
flutter步骤Stepper
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。