如何更改CircularProgressIndicator的颜色?
颜色的值是Animation< color >的实例,但我希望有一种更简单的方法来改变颜色,没有动画的麻烦。
如何更改CircularProgressIndicator的颜色?
颜色的值是Animation< color >的实例,但我希望有一种更简单的方法来改变颜色,没有动画的麻烦。
当前回答
valueColor:new AlwaysStoppedAnimation<Color>(Colors.yellow),
其他回答
只需将此代码写入应用程序的主题数据
ThemeData(
progressIndicatorTheme: ProgressIndicatorThemeData(
color: Colors.grey.shade700,),)
试试这个:
CircularProgressIndicator(
color: Colors.yellow, // Change your color here
),
可以使用accentColor作为widget的前景色。它可以改变任何前景小部件的颜色,包括circularprogressbar。
void main() => runApp(
MaterialApp(
title: 'Demo App',
home: MainClass(),
theme: ThemeData(accentColor: Colors.black),
),
);
CircularProgressIndicator(
backgroundColor: Colors.amberAccent,
semanticsLabel: 'Linear progress indicator',
),
使用progressIndicatorTheme允许为进度指示器定义一个主题。
ThemeData(
progressIndicatorTheme: ProgressIndicatorThemeData(color: Colors.white),
)