flutter_picker icon indicating copy to clipboard operation
flutter_picker copied to clipboard

No way to show just the picker widget (no modal)

Open dvorapa opened this issue 6 years ago • 4 comments

I tried numerous ways from the docs, but none of them allowed me to just show Picker() in the place I needed without any modal/dialog/box. There should be such way and it should be well documented

dvorapa avatar Jul 07 '19 14:07 dvorapa

Using makePicker, you can get widget.

yangyxd avatar Jul 08 '19 08:07 yangyxd

I tried with no success. Got an error stacktrace that makePicker does not produce type Widget needed (or something similar, not sure at the moment).

dvorapa avatar Jul 08 '19 19:07 dvorapa

Any update on this? We tried to insert a picker in our own place and get build errors as well.

zerox1212 avatar Nov 04 '19 14:11 zerox1212

This works for me inside a class that extends StatelessWidget:

Widget _numberPicker() {
    Picker picker = Picker(
      adapter: NumberPickerAdapter(data: [
        NumberPickerColumn(begin: 0, end: 9),
        NumberPickerColumn(begin: 0, end: 9),
      ]),
      delimiter: [
        PickerDelimiter(child: Container(width: 10.0)),
      ],
      hideHeader: true,
    );
    return picker.makePicker();
  }

  Widget _transactionBody(BuildContext context, Location location) {
    LocationBloc locationBloc = BlocProvider.of<LocationBloc>(context);
    return Container(
      padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16),
      child: Column(
        children: <Widget>[
          KpiWidget(),
          _numberPicker(),
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                _button('Cancel', () => locationBloc.add(TransactionCanceled()),
                    secondary: true),
                _button(
                    'Confirm', () => locationBloc.add(TransactionConfirmed())),
              ],
            ),
          )
        ],
      ),
    );
  }

maganap avatar Jan 26 '20 23:01 maganap

This example should be included in the docs

robindijkhof avatar Oct 18 '22 14:10 robindijkhof