picker method
Callback to display picker.
The currently selected DateTimeRange is passed to currentDateTimeRange
.
ピッカーを表示するためのコールバック。
currentDateTimeRange
に現在選択中のDateTimeRangeが渡されます。
Implementation
@override
Future<DateTimeRange?> picker(
BuildContext context,
DateTimeRange currentDateTimeRange,
) async {
final now = DateTime.now();
final nowRange = defaultDateTimeRange;
final date = await showDateRangePicker(
context: context,
helpText: helpText,
cancelText: cancelText,
confirmText: confirmText,
locale: locale,
initialEntryMode: initialEntryMode,
errorFormatText: errorFormatText,
errorInvalidText: errorInvalidText,
fieldStartHintText: fieldStartHintText,
fieldStartLabelText: fieldStartLabelText,
fieldEndHintText: fieldEndHintText,
fieldEndLabelText: fieldEndLabelText,
firstDate: startDate ??
(nowRange?.start ?? now).subtract(const Duration(days: 365)),
initialDateRange: currentDateTimeRange,
lastDate: endDate ??
(nowRange?.end ?? now).add(
const Duration(days: 365),
),
builder: (context, child) {
final theme = Theme.of(context);
return Theme(
data: theme.copyWith(
datePickerTheme: theme.datePickerTheme.copyWith(
rangeSelectionBackgroundColor: theme.primaryColor,
),
),
child: child!,
);
},
);
return date;
}