Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter: How to size progress indicator inside the container?

Container(
  height: 150,
  width: 150,
  child: _loading
      ? Container(
          height: 50,
          width: 50,
          child: CircularProgressIndicator(),
        )
      : ElevatedButton(
          style: ButtonStyle(
              backgroundColor: MaterialStateProperty.all<Color>(Colors.blue)),
          onPressed: () {},
          child: Text('update'),
        ),
);

I am trying to switch button to the CircularProgressIndicator() like the above code. However, the indicator’s size does not set to the parent’s container size (width height 50), but it is set to the grandpa Container (width height 150). Is there any way that I can set the size to 50 px container?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Wrap the CircularProgressIndicator in a FittedBox

Like so:

Container(
  height: 50,
  width: 50,
  child: FittedBox(child:  CircularProgressIndicator()),
)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading