代码之家  ›  专栏  ›  技术社区  ›  Colin Ricardo

CupertinoApp中的样式化材质小部件

  •  0
  • Colin Ricardo  · 技术社区  · 7 年前

    我怎样才能改变 CircularProgressIndicator

    颜色的值是 Animation<Color>

    0 回复  |  直到 7 年前
        1
  •  135
  •   Pang Ajmal PraveeN    8 年前

    这对我有效:

    valueColor: new AlwaysStoppedAnimation<Color>(Colors.blue),
    
        2
  •  38
  •   Alciomar Hollanda    7 年前

    您可以添加此代码。

      CircularProgressIndicator(
         valueColor: new AlwaysStoppedAnimation<Color>(Colors.white),
      ),
    
        3
  •  13
  •   Haileapp    8 年前

    accentColor circularprogressbar 你可以这样使用:

    void main() => runApp(
      MaterialApp(
        title: 'Demo App',
        home: MainClass(),
        theme: ThemeData(accentColor: Colors.black),
      ),
    );
    
        4
  •  11
  •   Sanjayrajsinh    6 年前

    解决问题的三种方法

    1) 使用 valueColor

    CircularProgressIndicator(
         valueColor: new AlwaysStoppedAnimation<Color>(Colors.blue),
    ),
    

    2) 套 accentColor 在你的主体 MaterialApp 这是最好的方法,因为你不想在使用时一直设置颜色 CircularProgressIndicator 小装置

      MaterialApp(
            title: 'My App',
            home: MainPAge(),
            theme: ThemeData(accentColor: Colors.blue),
          ),
    

    Theme 小装置

    Theme(
          data: Theme.of(context).copyWith(accentColor: Colors.red),
          child: new CircularProgressIndicator(),
    )
    
        5
  •  7
  •   Akshay Nandwana    8 年前

    主题是一个小部件,您可以将其插入到小部件树的任何位置。 它用自定义值覆盖当前主题 试试这个:

    new Theme(
          data: Theme.of(context).copyWith(accentColor: Colors.yellow),
          child: new CircularProgressIndicator(),
        );
    

    https://gitter.im/flutter/flutter?at=5a84cf9218f388e626a51c2d

        6
  •  2
  •   Parth Bhanderi    6 年前

    这对我很有用。

    Container(
                child: Center(
                  child: CircularProgressIndicator(
                    valueColor: AlwaysStoppedAnimation<Color>(appColor),
                  ),
                ),
              )
    
        7
  •  0
  •   Ahmad Wael Pepe Valdivia    6 年前

    main.dart 设定主题 accentColor ,和 CircularProgressIndicator 会用那种颜色

    void main() => runApp(new MaterialApp(
      theme: ThemeData(primaryColor: Colors.red, **accentColor:  Colors.yellowAccent**),
      debugShowCheckedModeBanner: false,
      home: SplashPage()
    ));
    
        8
  •  -1
  •   Swaroop Maddu    7 年前

    默认情况下,它从主题数据继承重音颜色

      void main() => runApp(new MaterialApp(
      theme: ThemeData(
                     primaryColor: Colors.blue,
                     accentColor:  Colors.blueAccent,
                     //This will be the color for CircularProgressIndicator color
                   ),
      home: Homepage()
        ));
    

    另一种方法是使用这样的预定义主题数据

    void main() => runApp(new MaterialApp(
      theme: ThemeData.light().copyWith(
                     accentColor:  Colors.blueAccent,
                     //change the color for CircularProgressIndicator color here
                   ),
      home: Homepage()
        ));
    

    或者您可以直接在CircularProgressIndicator中更改此颜色属性,如下所示

    CircularProgressIndicator(
             valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
                        ),