Created
May 24, 2022 11:08
-
-
Save CoMatu/d8416739151e28768ca31ef4825611da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void _showDatePicker(context) async { | |
| Picker( | |
| itemExtent: padding35, | |
| adapter: adapter, | |
| hideHeader: true, | |
| cancelText: 'ОТМЕНА', | |
| cancelTextStyle: Theme.of(context).colorScheme.subtitle2, | |
| confirmText: 'OK', | |
| confirmTextStyle: | |
| Theme.of(context).colorScheme.subtitle2.copyWith(color: Colors.red), | |
| title: Text( | |
| 'Выберите дату', | |
| style: Theme.of(context).colorScheme.h4, | |
| ), | |
| textStyle: Theme.of(context).colorScheme.subtitle2, | |
| selectionOverlay: Container( | |
| margin: const EdgeInsets.only( | |
| left: padding10, | |
| right: padding10, | |
| ), | |
| decoration: const BoxDecoration( | |
| border: Border( | |
| top: BorderSide(width: 1.0, color: c_0xff000000), | |
| bottom: BorderSide(width: 1.0, color: c_0xff000000), | |
| ), | |
| ), | |
| ), | |
| squeeze: 1.0, | |
| diameterRatio: 1.0, | |
| onConfirm: (picker, list) { | |
| log(picker.adapter.toString()); | |
| setState(() { | |
| chosenDateTime = DateTime.parse(picker.adapter.toString()); | |
| widget.onDateTimeSelected(chosenDateTime ?? DateTime.now()); | |
| }); | |
| }).showDialog(context); | |
| } | |
| final adapter = DateTimePickerAdapter( | |
| type: PickerDateTimeType.kDMY, | |
| value: DateTime( | |
| DateTime.now().year - 18, | |
| DateTime.now().month, | |
| DateTime.now().day, | |
| ), | |
| maxValue: DateTime( | |
| DateTime.now().year - 17, | |
| DateTime.now().month, | |
| DateTime.now().day, | |
| ), | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment