El-Mazouzi / custom_date_range_picker

MIT License
14 stars 33 forks source link

Asynchrony problem #16

Open minhto2811 opened 4 months ago

minhto2811 commented 4 months ago

Like other date pickers, I think the showCustomDateRangePicker function should be an asynchronous function.

tuxsoft commented 2 months ago
Future<DateTimeRange?> customDateRangePickerAsync() async {
    final completer = Completer<DateTimeRange?>();
    DateTime? startDate;
    DateTime? endDate;
    showCustomDateRangePicker(
      context,
      dismissible: true,
      minimumDate: DateTime.now().subtract(const Duration(days: 0)),
      maximumDate: DateTime.now().add(const Duration(days: 30)),
      endDate: endDate,
      startDate: startDate,
      backgroundColor: Theme.of(context).scaffoldBackgroundColor,
      primaryColor: Theme.of(context).colorScheme.onPrimaryContainer,
      onApplyClick: (start, end) {
        DateTimeRange d = DateTimeRange(start: start, end: end);
        completer.complete(d);
      },
      onCancelClick: () {
        completer.complete(null);
      },
    );
    return completer.future;
  }
minhto2811 commented 2 months ago

I would like to express my sincere thanks to you for your valuable support in the recent project. Your help helped me to complete the task on time and achieve the desired results. Thanks again! Have a great day!

On Thu, 22 Aug 2024 at 02:43, tuxsoft @.***> wrote:

Future<DateTimeRange?> customDateRangePickerAsync() async { final completer = Completer<DateTimeRange?>(); DateTime? startDate; DateTime? endDate; showCustomDateRangePicker( context, dismissible: true, minimumDate: DateTime.now().subtract(const Duration(days: 0)), maximumDate: DateTime.now().add(const Duration(days: 30)), endDate: endDate, startDate: startDate, backgroundColor: Theme.of(context).scaffoldBackgroundColor, primaryColor: Theme.of(context).colorScheme.onPrimaryContainer, onApplyClick: (start, end) { DateTimeRange d = DateTimeRange(start: start, end: end); completer.complete(d); }, onCancelClick: () { completer.complete(null); }, ); return completer.future; }

— Reply to this email directly, view it on GitHub https://github.com/El-Mazouzi/custom_date_range_picker/issues/16#issuecomment-2302884928, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6RV4HVZBFZMBWYYPB2TMDTZSTUXZAVCNFSM6AAAAABKODVE6OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBSHA4DIOJSHA . You are receiving this because you authored the thread.Message ID: @.***>