Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception #38

Open
McSam94 opened this issue Apr 17, 2020 · 3 comments
Open

Unhandled Exception #38

McSam94 opened this issue Apr 17, 2020 · 3 comments

Comments

@McSam94
Copy link

McSam94 commented Apr 17, 2020

I getting this error Unhandled Exception: 'package:date_range_picker/date_range_picker.dart': Failed assertion: line 1280 pos 10: '!initialLastDate.isAfter(lastDate)': initialDate must be on or before lastDate and the dialog won't show up. Any help would appreciated. 🙏
This is my code :

Future<List<DateTime>> _showDateRangePicker() async {
    final List<DateTime> pickedDateRange = await DateRangePicker.showDatePicker(
      context: context,
      initialFirstDate: new DateTime(2020, 1, 1),
      initialLastDate: new DateTime(2020, 4, 1),
      firstDate: new DateTime(2015),
      lastDate: new DateTime(2020)
    );

    if(pickedDateRange == null && pickedDateRange.length < 2) {
      return [];
    }

    return pickedDateRange;
  }
@antonio555
Copy link

antonio555 commented Apr 23, 2020

Hi @McSam94,
I had the same error ,
the problem is between initialFirstDate & lastDate

when you initiate the lastSAte like this: new DateTime(2020), you'll have the same date as the initialFirstDate I think so that's why it caught that exception:

Capture
Try to change the lastDate like this
lastDate: (new DateTime.now()).add(new Duration(days: 7))

@arutkayb
Copy link

I think the problem is caused by lastDate: new DateTime(2020) is not greater than initialLastDate: new DateTime(2020, 4, 1)

@etienneyoufeel
Copy link

@arutkayb true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants