Skip to content

Year Picker Error with Range when page is full (multiple of 12 + 1) #118

@cnschnei-btc

Description

@cnschnei-btc

There is an error with the Year Picker Range. If the range of dates between the firstDate and the lastDate matches the pattern: 12 * x + 1. So for example 13, 25, ....

Example:
We have 25 years, from 2000 to 2024, then the 2024th year wont get a new page, in this case it would be the 3rd page.

If then the selectedDate value is the 2024th year, there will be a range error 0...1, -2.

════════ Exception caught by widgets library ═══════════════════════════════════
RangeError (index): Invalid value: Not in inclusive range 0..1: -2
The relevant error-causing widget was:
════════════════════════════════════════════════════════════════════════════════

I wont get any more details but i figured it out by tweaking the values.

Example Code:

YearPicker.single(
  selectedDate: DateTime(2024),
  firstDate: DateTime(2000),
  lastDate: DateTime(2024),
  onChanged: (value) {
     ...
  },
),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions