Set width and height for Cupertino Picker

4.3k Views Asked by At

Cupertino Picker in flutter takes 100% width.

How do we give it custom styling? Height, Width, Borders?

I tried putting it inside a container with width and all, didn't work.Instead there was a weird soft edged background when I gave container a color.

2

There are 2 best solutions below

0
On BEST ANSWER

Answering my own question for the time being,

I got a workaround by making the following tree:

  • Row

    • Sized box(width:20)

    • Expanded

      • Cupertino Picker
    • Sized Box(width: 20)

I tried multiple workarounds but none worked

A better approach is highly appreciated!

0
On

you can try wrapping it up with a container and setting width or height

        Container(
              height: 250,
              child: CupertinoPicker(
                itemExtent: 32,
                onSelectedItemChanged: (value) {
                  setState(() {});
                },
              children:
                        ...
        }),