Flutter Stepper 步骤

步骤组件是用来约束用户操作的,第一步完成后才能进入下一步。所有步骤都完成,才可进行提交操作。 

参数详解

属性说明
steps步骤内容集合

physics

步骤跳转动画
typeStepperType.vertical
currentStep步骤位置
onStepTapped状态改变时触发
onStepContinue点击 continue 时触发
onStepCancel点击 cancel 时触发
controlsBuilder自定义控件

 

以下是每一步(Step)的属性
title主标题
subtitle副标题
content内容
stateStepState.indexed 此为默认状态,步骤数
StepState.eidting 编辑状态
StepState.complete 完成状态
StepState.disabled 不可用状态
StepState.error 错误状态
isActive导航是否高亮

代码示例

Stepper(
  //当前步骤下标
  currentStep:this.currentStepIndex,
  //上一步
  onStepCancel: (){
    setState(() {
      currentStepIndex--; 
    });
  },
  //下一步
  onStepContinue: (){
    setState(() {
      currentStepIndex++; 
    });
  },
  //自定义按钮
  controlsBuilder:(BuildContext context, {VoidCallback onStepContinue, VoidCallback onStepCancel}){
    return Row(
      children: <Widget>[
        FlatButton(
          onPressed: onStepContinue,
          child: const Text('下一步'),
        ),
        FlatButton(
          onPressed: onStepCancel,
          child: const Text('上一步'),
        ),
      ],
    );
  },
  // 步骤集合
  steps: <Step>[
    Step(
      title: Text('我是标题1'),
      content: Text('我是内容1我是内容1我是内容1我是内容1我是内容1我是内容1我是内容1'),
      subtitle:Text('我是副标题1111'),
      isActive: true,
      
    ),
    Step(
      title: Text('我是标题1'),
      content: Text('我是内容1我是内容1我是内容1我是内容1我是内容1我是内容1我是内容1'),
    ),
    Step(
      title: Text('我是标题1'),
      content: Text('我是内容1我是内容1我是内容1我是内容1我是内容1我是内容1我是内容1'),
    ),
    Step(
      title: Text('我是标题1'),
      content: Text('我是内容1我是内容1我是内容1我是内容1我是内容1我是内容1我是内容1'),
    ),
  ],

),

示例代码 为的更加清楚组件使用,并未添加校验,不停点击下一步或上一步会报错 steps.length': is not true。越界了!!

效果图

完整代码

查看完整代码

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

马志武

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值