【问题标题】:How to put a CircularProgressIndicator inside another CircularProgressIndicator in Flutter?如何将 CircularProgressIndicator 放入 Flutter 中的另一个 CircularProgressIndicator 中?
【发布时间】:2020-07-12 18:06:06
【问题描述】:

我试过这样做,但结果一个接一个。 CircularProgressIndicator 是堆叠在一起的,而不是像我在下面的代码中尝试过的那样在里面:

body: Center(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            SizedBox(
              height: 200,
              width: 200,
              child: Column(
                children: <Widget>[
                  CircularProgressIndicator(
                backgroundColor: Colors.pinkAccent,
                strokeWidth: 30.0,
                value: 0.7,
                valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
              ),
                  SizedBox(
                    height: 150,
                    width: 150,
                    child: CircularProgressIndicator(
                      backgroundColor: Colors.red,
                      strokeWidth: 10.0,
                      value: 0.7,
                      valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
                    ),
                  ),
              ],
            ),
            ),
          ],
        ),
      ),

【问题讨论】:

    标签: android ios flutter dart progress-indicator


    【解决方案1】:

    您必须使用 Stack 小部件将这些小部件堆叠在一起

    Stack(
        children: <Widget>[
          SizedBox(
            height: 200,
            width: 200,
            child: CircularProgressIndicator(
              backgroundColor: Colors.pinkAccent,
              strokeWidth: 30.0,
              value: 0.7,
              valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
            ),
          ),
          Positioned(
            left: 25,
            top: 25,
            child: SizedBox(
              height: 150,
              width: 150,
              child: CircularProgressIndicator(
                backgroundColor: Colors.red,
                strokeWidth: 10.0,
                value: 0.7,
                valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
              ),
            ),
          )
        ],
      ),
    

    输出

    【讨论】:

    • 感谢您的帮助! ?
    猜你喜欢
    • 2020-03-30
    • 2020-05-24
    • 2021-08-26
    • 2023-03-16
    • 2019-05-23
    • 1970-01-01
    • 2019-06-23
    • 1970-01-01
    • 2023-02-14
    相关资源
    最近更新 更多