showExpressiveDateRangePicker function
Raises an ExpressiveDateRangePicker in an ExpressiveDatePickerDialog and resolves to the range confirmed with OK (OK waits for both ends), or null when cancelled.
Implementation
Future<({DateTime start, DateTime end})?> showExpressiveDateRangePicker({
required BuildContext context,
ExpressiveComponentThemeData? style,
DateTime? initialStart,
DateTime? initialEnd,
DateTime? firstDate,
DateTime? lastDate,
bool Function(DateTime day)? selectableDay,
String? title,
DateTime? today,
int? firstDayOfWeek,
String? confirmLabel,
String? dismissLabel,
}) {
final strings = ExpressiveLocalizations.of(context);
var start = initialStart;
var end = initialEnd;
return showExpressiveDialog<({DateTime start, DateTime end})>(
context: context,
builder: (context) => StatefulBuilder(
builder: (context, update) {
final s = start;
final e = end;
return ExpressiveDatePickerDialog(
style: style,
dismiss: ExpressiveTextButton(
dismissLabel ?? strings.cancel,
onPressed: () => Navigator.of(context).pop(),
),
confirm: ExpressiveTextButton(
confirmLabel ?? strings.ok,
onPressed: s == null || e == null
? null
: () => Navigator.of(context).pop((start: s, end: e)),
),
child: ExpressiveDateRangePicker(
style: style,
start: s,
end: e,
onChanged: (ns, ne) => update(() {
start = ns;
end = ne;
}),
firstDate: firstDate,
lastDate: lastDate,
selectableDayPredicate: selectableDay,
title: title,
currentDate: today,
firstDayOfWeek: firstDayOfWeek,
),
);
},
),
);
}