Skip to content

Instantly share code, notes, and snippets.

@CoMatu
Created May 24, 2022 11:08
Show Gist options
  • Select an option

  • Save CoMatu/d8416739151e28768ca31ef4825611da to your computer and use it in GitHub Desktop.

Select an option

Save CoMatu/d8416739151e28768ca31ef4825611da to your computer and use it in GitHub Desktop.
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