preferredEndDate method

  1. @override
Future<DateTime> preferredEndDate(
  1. DateTime? maximumDate
)
override

Called when the renew interaction allows to customize the end date programmatically. You can prompt the user for the number of days to renew, for example.

The returned date can't exceed maximumDate.

Implementation

@override
Future<DateTime> preferredEndDate(DateTime? maximumDate) async {
  DateTime start = (license.license.rights.end ?? DateTime.now());
  DateTime end = maximumDate ?? DateTime.now().add(const Duration(days: 365));
  return await showDatePicker(
          context: context,
          initialDate: start,
          firstDate: start,
          lastDate: end) ??
      start;
}