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

FormBuilderDateRangePicker example #290

Closed
jaxnz opened this issue May 25, 2020 · 4 comments
Closed

FormBuilderDateRangePicker example #290

jaxnz opened this issue May 25, 2020 · 4 comments
Labels
question Further information is requested

Comments

@jaxnz
Copy link

jaxnz commented May 25, 2020

Hi @danvick

Could you add an example for FormBuilderDateRangePicker / FormBuilderDateRangePickerState in documentation? I'm trying to Implement, but unsure how.

EDIT: Sorry - I am Implementing it like this:

FormBuilderDateRangePicker(
   attribute: 'date', 
   firstDate: DateTime.utc(2019), 
   lastDate: DateTime.now(), 
   format: DateFormat('dd/MM/yyyy')
),

With this I am getting an error:

NoSuchMethodError: invalid member on null: 'initialValue'

Actually.. I have kinda figured it out.. Still would like a example. I am going do a PR to tidy it up as its quite broken and hard to use.

Second EDIT:
@danvick would you consider baking in date_range_picker - the author is no longer contributing and some assertions are broken. For example if I give initialValue these parameters:

initialValue: [DateTime.now().subtract(Duration(days: 30)), DateTime.now()]

I get the assertion error: 'initialDate must be on or after firstDate'

But if I give initialValue these parameters, it works fine

initialValue: [DateTime.now().subtract(Duration(days: 30)), DateTime.now().subtract(Duration(seconds: 1))]

Jackson

@danvick
Copy link
Collaborator

danvick commented May 29, 2020

Hi @jaxnz,
I think that the assertion is correct. The assertion is there to make sure that the date range you have as your initial value falls between firstDate and lastDate.

The assertion is however strict, down to the millisecond, that if both the end time of your initialValue and your lastDate are DateTime.now() the assertion fails. i.e. DateTime.now() < DateTime.now() is NOT true.

How would you have it?

@danvick danvick added the question Further information is requested label May 29, 2020
@jaxnz
Copy link
Author

jaxnz commented May 31, 2020

The assertion states: 'initialDate must be on or before lastDate' this indicates that initialLastDate should be greater than or equal to lastDate - if lastDate is DateTime.now() then it should allow DateTime.now() as a value in FormBuilderDateRangePicker.initialValue.

So I think the assertion should be:

  assert(initialLastDate.isAfter(lastDate.subtract(Duration(seconds: 1))),
      'initialDate must be on or before lastDate');

This means the user doesn't need to fumble around with subtracting from DateTime.now()

I also think the FormBuilderDateRangePicker.initialValue should be @required or have a default value, as otherwise it shows just a blank widget.

If you agree, I am happy to do a PR

@mdeandrea-mrmilu
Copy link
Contributor

Can be close this issue?

@deandreamatias
Copy link
Collaborator

Closed issue because example of FormBuilderDateRangePickerState alreasy exist

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

No branches or pull requests

4 participants