Articles in this section
Category / Section

How to create a circular progress bar using the Flutter radial gauge (SfRadialGauge)

5 mins read

Description

This article describes how to create a circular progress bar using the Flutter Radial Gauge widget.

Solution

You can achieve a circular progress bar by using the range pointer and annotation features of radial gauge widget.

Step 1: Create a radial gauge widget and add a radial axis into it.

@override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Center(
        child: SfRadialGauge(
          axes: <RadialAxis>[RadialAxis()],
        ),
      ),
    );
  }

 

Step 2: Set the startAngle and endAngle as 270 to get a full circular scale and customize the axis look as required for progress bar.

axes: <RadialAxis>[
            RadialAxis(
              showLabels: false,
              showTicks: false,
              startAngle: 270,
              endAngle: 270,
              minimum: 0,
              maximum: 100,
              radiusFactor: 0.85,
              axisLineStyle: AxisLineStyle(
                  color: Color.fromRGBO(106, 110, 246, 0.2),
                  thicknessUnit: GaugeSizeUnit.factor,
                  thickness: 0.1),
            ),
          ],

 

Step 3: Add the RangePointer and set the value to annotate the progress in the radial scale.

pointers: <GaugePointer>[
                  RangePointer(
                      value: _pointerValue,
                      cornerStyle: CornerStyle.bothCurve,
                      enableAnimation: true,
                      animationDuration: 1200,
                      animationType: AnimationType.ease,
                      sizeUnit: GaugeSizeUnit.factor,
                      color: const Color(0xFF6A6EF6),
                      width: 0.1),
                ]

 

Step 4: Add a Text widget as GaugeAnnotation to display the current progress value of radial scale.

  annotations: <GaugeAnnotation>[
                  GaugeAnnotation(
                      angle: 0,
                      positionFactor: 0.25,
                      widget: Row(
                        children: <Widget>[
                          Container(
                            width: 100,
                            child: Text(
                              _annotationValue,
                              style: TextStyle(
                                  fontFamily: 'Times',
                                  fontSize: 22,
                                  fontWeight: FontWeight.w400,
                                  fontStyle: FontStyle.italic),
                            ),
                          ),
                        ],
                      )),
                ],

 

Step 5: Update the value of range pointer and text of the gauge annotation in real time to display the progress. In this demo, the value of range pointer and text of annotation are updated periodically by using a timer.

@override
  void initState() {
    _random = Random();
    _timer = Timer.periodic(const Duration(milliseconds: 1200), (_timer) {
      setState(() {
        int _value = _random.nextInt(100);
        if (_value > 4 && _value < 100) {
          _pointerValue = _value.toDouble();
          _annotationValue = _value.toString() + ' %';
        }
      });
    });
    super.initState();
  }

 

Output

Progress bar

 

View the Github Sample here.


Conclusion

I hope you enjoyed learning about how to create a circular progress bar using the Flutter Radial Gauge widget.

You can refer to our  Flutter RadicalGauge feature tour page to learn about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please  to leave a comment
Access denied
Access denied