I am an ios developer who is new to Flutter. In my app, I have TextFormField, whose input type is the options give in the picker. I am struggling to show the picker view as an input view instead of the keyboard. My desired output is as follows
Asked
Active
Viewed 1,195 times
1 Answers
1
TextEditingController _controller = TextEditingController();
Future<void> _selectedNumber(BuildContext context) async {
int number = await showCupertinoModalPopup(
context: context,
builder: (context) => Container(
height: 250,
child: CupertinoPicker(
itemExtent: 50,
onSelectedItemChanged: (int value) {
_controller.text = (value + 1).toString();
},
children: numbers
.map(
(number) => Text(number.toString()),
)
.toList(),
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: GestureDetector(
onTap: () => _selectedNumber(context),
child: AbsorbPointer(
child: TextFormField(
keyboardType: TextInputType.datetime,
controller: _controller,
decoration: InputDecoration(
hintText: 'Select A Number',
prefixIcon: Icon(
Icons.format_list_numbered,
),
),
),
),
),
),
);
}
}
Is this what you are looking for?

wcyankees424
- 2,554
- 2
- 12
- 24
-
If this is what you where look for you can accept it as the answer if not I can help you find what you want – wcyankees424 Apr 04 '20 at 02:10