editDialog method

Future<void> editDialog()

Implementation

Future<void> editDialog() async {
  if (context != null && callback != null) {
    DateTime date = DateTime.now();
    try {
      date = DateTime.parse(pref.value.toString());
    } catch (e) {}

    final DateTime? day = await showDatePicker(
        context: context!,
        initialDate: date,
        firstDate: DateTime(DateTime.now().year - 30),
        lastDate: DateTime(DateTime.now().year + 30));

    if (day != null) {
      pref.value = day;
      callback!(pref);
    }
  }
}