selectDate method
Implementation
Future<String> selectDate({required BuildContext context}) async {
DateTime selectedDate = DateTime.now();
final DateTime? picked = await showDatePicker(
context: context,
locale: const Locale('pt_BR'),
initialDate: selectedDate,
firstDate: DateTime(2000, 1),
lastDate: DateTime(2101),
builder: (context, child) {
return DatePickerDialog(
firstDate: DateTime(2000, 1),
lastDate: DateTime(2101),
cancelText: 'Cancelar',
currentDate: selectedDate,
);
},
);
if (picked != null && picked != selectedDate) {
selectedDate = picked;
return formatarDataPadraoBR(data: "${selectedDate.toLocal()}");
}
return formatarDataPadraoBR(data: "${DateTime.now().toLocal()}");
}