Home > Blockchain >  Flutter: How to size progress indicator inside the container?
Flutter: How to size progress indicator inside the container?

Time:01-27

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?

CodePudding user response:

Wrap the CircularProgressIndicator in a FittedBox

Like so:

Container(
  height: 50,
  width: 50,
  child: FittedBox(child:  CircularProgressIndicator()),
)
  •  Tags:  
  • Related