How to set width of CupertinoButton in Flutter?

Issue

Am I missing something obvious here?
Setting minSize on CupertinoButton button sets width and height (see image).

How do I set only the width?

Thanks in advance.

CupertinoButton's minSize

Solution

Wrap it in a SizedBox and set width and height.

Example

SizedBox(
   width: 500,
   height: 200
   child: CupertinoButton(
       onPressed: (){},
       child: Text("Click Me", style: TextStyle(color: Colors.white)),
       color: Colors.green
   )
)

NOTE: It is best practice to use SizedBox as it is more efficient since you only need to change the width and height.

Check this.
Flutter: SizedBox Vs Container, why use one instead of the other?

Answered By – Josteve

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.