簡體   English   中英

如何將 CircularProgressIndicator 放在 Flutter 中的另一個 CircularProgressIndicator 中?

[英]How to put a CircularProgressIndicator inside another CircularProgressIndicator in Flutter?

我嘗試這樣做,但結果是一個接一個。 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),
                    ),
                  ),
              ],
            ),
            ),
          ],
        ),
      ),

您必須使用 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),
          ),
        ),
      )
    ],
  ),

輸出

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM