flutter 自定义步进器抖动

gudnpqoy  于 2023-03-19  发布在  Flutter
关注(0)|答案(1)|浏览(151)

image
我想实现这种步进机
到目前为止,我已经尝试使用pub.dev中的AnotherStepper

List<StepperData> stepperData = [
    StepperData(
      title: StepperText(
        "Order Placed",
        textStyle: const TextStyle(
          color: Colors.grey,
        ),
      ),
      subtitle: StepperText("Your order has been placed"),
    ),
    StepperData(
      title: StepperText("Preparing"),
      subtitle: StepperText("Your order is being prepared"),
    ),
    StepperData(
      title: StepperText("On the way"),
      subtitle: StepperText(
          "Our delivery executive is on the way to deliver your item"),
    ),
    StepperData(
      title: StepperText("Delivered",
          textStyle: const TextStyle(
            color: Colors.grey,
          )),
    ),
  ];
AnotherStepper(
                // this is removed 
                
                // dotWidget: Container(
                //   padding: EdgeInsets.all(8),
                //   decoration: BoxDecoration(
                //       color: Colors.red,
                //       borderRadius: BorderRadius.all(Radius.circular(30))),
                //   child: Icon(Icons.fastfood, color: Colors.white),
                // ),                      
                stepperList: stepperData,
                stepperDirection: Axis.vertical,
                gap: 20,
                iconWidth: 24,
                iconHeight: 24,
                activeBarColor: Colors.green,
                inActiveBarColor: Colors.grey,
                activeIndex: 1,
                barThickness: 8,
              ),

我想在activeIndex的基础上有条件地灰化subtitle的样式,并且我想实现点颜色。我该怎么做呢?如果能提供帮助,我将不胜感激。
所需图像
image
输出图像
image

lrpiutwd

lrpiutwd1#

您需要一个简单的if else语句来实现使用状态管理定义isActive

StepperData(
      title: StepperText(
        "Order Placed",
        textStyle: const TextStyle(
          color: isActive ?Colors.grey:Colors.black,
        ),
      ),
      subtitle: StepperText("Your order has been placed",
         textStyle: const TextStyle(
          color: isActive ?Colors.grey:Colors.black,
        ),),
    ),

相关问题