I am using flutter numberpicker to build a mobile app. The default size of the widget is 50px by 100px. The size is too large for small screens. How should I make it automatically resize by specifying the right height and width?

Thanks. Any ideas and thoughts are appreciated.

Solution 1: Nisanth Reddy

You can use a combination of SizedBox and FittedBox to achieve any kind of scale manipulation of Widgets.

For your case, you can use it like this,

  width: 75,
  child: FittedBox(
    fit: BoxFit.contain,
    child: NumberPicker(
      value: _currentValue,
      minValue: 0,
      maxValue: 100,
      onChanged: (value) => setState(() => _currentValue = value),

If you use it normally or don't give the width param in above code, tt looks like this.

enter image description here

But if you give a width of 75 like in the code above, it looks like this.

enter image description here