繁体   English   中英

flutter - 百分比指示器 progressColor

[英]flutter - percent indicator progressColor

我使用percent_indicator包。 我用 Gesturedetetor 包裹了 CircularPercentIndicator,我在每次触摸 onTap 函数时增加启动参数。

每次我点击将数值加一时,CircularPercentIndicator 颜色都会重新开始。 例如; 我的起始参数是 8,一旦我触摸它,我的起始参数是 9,但 CircularPercentIndicator 从 0 开始到 9。

整数开始 = 0;

GestureDetector(
          child: CircularPercentIndicator(
            radius: 100.0,
            lineWidth: 13.0,
            animation: true,
            percent: start.toDouble() / 100,
            center: Text(
              start.toString(),
              style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
            ),
            footer: const Text(
              "Sales this week",
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17.0),
            ),
            circularStrokeCap: CircularStrokeCap.round,
            progressColor: Colors.purple,
          ),
          onTap: () {
            start = start + 1;
            setState(() {});
            print(start.toString());
          },
        ),

如果你查看插件源代码,插件是这样开发的,它会更新进度,并运行_animation.forward(),这将使动画从0-currentProgress开始。

我找到了解决方案。 有一个像下面这样的属性。

animateFromLastPercent: true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM