[英]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.