Im trying to display the CircularProgressIndicator
in my flutter app on click of button but it does not render the circular progress bar, but as soon as I change the code to use LinearProgressBar
the progress bar comes without any issue. So wanted to know is there any special setting which I need to display the circular loading indicator?
Works
if (_isFetching) {
return new Scaffold(
body: new Center(
child: new SizedBox(
width: 40.0,
height: 40.0,
child: const LinearProgressIndicator(backgroundColor: Colors.black)),
));
}
Do not work
if (_isFetching) {
return new Scaffold(
body: new Center(
child: new SizedBox(
width: 40.0,
height: 40.0,
child: const CircularProgressIndicator(backgroundColor: Colors.black)),
));
}
In Flutter, progress can be displayed in two ways: CircularProgressIndicator: A CircularProgressIndicator is a widget that shows progress along a circle. It is a circular progress bar that spins to indicate that the application is busy or on hold.
Your overlay loader widget can be any widget you want. For example you can import the package flutter_spinkit and customise your widget like this. To do that just pass your widget to overlayWidget and set useDefaultLoading to false . Another customisation you can do is configure the opacity of the overlay.
So, we can adjust the size of a CircularProgressIndicator by simply using a Container or a SizedBox widget. Note: It would be best if you give the Container or SizedBox the width equal to the height. If the width and height are different, the CircularProgressIndicator will become an ellipse.
Make sure the progress bar's value color is different from the parent widget's background color. Try this:
if (_isFetching) {
return Scaffold(
body: Center(
child: SizedBox(
width: 40.0,
height: 40.0,
child: const CircularProgressIndicator(
backgroundColor: Colors.black,
valueColor: AlwaysStoppedAnimation<Color>(Colors.red))),
));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With