Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CircularProgressIndicator not displayed in flutter

Tags:

flutter

dart

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)),
  ));
}
like image 415
Ajay Beniwal Avatar asked Jun 01 '18 09:06

Ajay Beniwal


People also ask

How do you use CircularProgressIndicator in flutter?

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.

How do you show loader in flutter?

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.

How do you reduce the size of a CircularProgressIndicator in flutter?

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.


1 Answers

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))),
  ));
}
like image 178
kine Avatar answered Sep 20 '22 13:09

kine