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,
),
),
),
),
),
),
);
}
}
Это то, что вы ищете?