简体   繁体   中英

How to create a circular progress bar in flutter

I am trying to figure out how to curve a fractionally sized box inside a container in flutter.

The code I currently have just creates a giant circle inside the border.

      decoration: BoxDecoration(border: Border.all(),
       shape: BoxShape.circle),
       width: 112,
       height: 112,
       child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
         children: [
         Flexible(
          child: FractionallySizedBox(
          widthFactor:.90,                
          child: Container(
          decoration: BoxDecoration(
          shape: BoxShape.circle,
          color: Colors.green,),),

Here is what I am trying to achieve (but with the green bar only showing 20% instead of the 100% shown here):

圆图

Why don't you use CircularProgressIndicator widget and a Text widget in a stack?

You can set strokeWidth and the progress of a circularProgressIndicator like this:

CircularProgressIndicator(
            value: yourProgress,
            strokeWidth: yourStrokeWidth)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM