showComicDateRangePicker function

Future<DesignDateRange?> showComicDateRangePicker(
  1. BuildContext context, {
  2. required DateTime firstDate,
  3. required DateTime lastDate,
  4. DesignDateRange? value,
  5. DateTime? currentDate,
  6. String? title,
  7. String? confirm,
  8. String? cancel,
})

Raises a ComicDateRangePicker in the dialog and returns the confirmed span, or null on dismissal.

final stay = await showComicDateRangePicker(context, firstDate: DateTime(2026), lastDate: DateTime(2027));

Implementation

Future<DesignDateRange?> showComicDateRangePicker(
  BuildContext context, {
  required DateTime firstDate,
  required DateTime lastDate,
  DesignDateRange? value,
  DateTime? currentDate,
  String? title,
  String? confirm,
  String? cancel,
}) {
  var picked = value;
  return showComicDialog<DesignDateRange>(
    context,
    builder: (context) => StatefulBuilder(
      builder: (context, setState) => ComicDialog(
        title: title ?? ComicLocalizations.of(context).chooseDate,
        content: [
          ComicDateRangePicker(
            firstDate: firstDate,
            lastDate: lastDate,
            value: picked,
            currentDate: currentDate,
            onChanged: (span) => setState(() => picked = span),
          ),
        ],
        actions: [
          ComicButton(
            cancel ?? DesignLocalizations.of(context).cancelButtonLabel,
            onPressed: () => Navigator.pop(context),
          ),
          ComicButton.filled(
            confirm ?? ComicLocalizations.of(context).choose,
            size: ComicButtonSize.small,
            onPressed: picked == null
                ? null
                : () => Navigator.pop(context, picked),
          ),
        ],
      ),
    ),
  );
}