0

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.

1 Answer 1

1

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,

SizedBox(
  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

3
  • @expectedAn Does this solve your use case ? May 18, 2021 at 18:14
  • Thanks @Nisanth, I will give it a try. If it works I will accept your answer.
    – expectedAn
    May 18, 2021 at 22:33
  • @expectedAn Alright. Do tell me if anything breaks or doesn't work, would love to solve it. May 19, 2021 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.