No way to show just the picker widget (no modal)
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
Using makePicker, you can get widget.
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).
Any update on this? We tried to insert a picker in our own place and get build errors as well.
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())),
],
),
)
],
),
);
}
This example should be included in the docs