iamvivekkaushik/DatePickerTimelineFlutter

Select dates from the past

Closed this issue ยท 13 comments

Is your feature request related to a problem? Please describe.
I am wanting to use this fantastic widget to select dates from the past. At present it seems to only work for future dates.

Describe the solution you'd like
Perhaps you could add a stateDate parameter that is set to today by default.

Describe alternatives you've considered
Fork the code and add the feature.

Additional context

Hi @mrwwalmsley, if you want the date to start at some previous time, then you can just pass that date to the constructor.

DatePickerTimeline(
  DateTime.now(),
  onDateChange: (date) {
    // New date selected
    print(date.day.toString());
  },
),

Instead of date.now() you can pass any date and the calendar will start from that particular date.

Hi @mrwwalmsley, can you confirm if this resolves your issue?

I am closing this issue.

Sorry for the late reply, I'm just getting on to implementing this functionality, and it doesn't seem to be working as I would like.

I want to set the current date to today... but allow the user to scroll back to select a day in the past.

The calendar timeline always starts on the current date.

See line 58 in date_picker_timeline.dart
DateTime _date = DateTime.now().add(Duration(days: index));

Any update on this? Can this PR #12 get merged in please?

I had no time to implement this, #12 have it implemented, you can use that version until it gets merged.

dependencies:
  date_picker_timeline:
    git:
      url: https://github.com/psygo/DatePickerTimelineFlutter.git

I tried to pass the date like this DateTime.now().add(Duration(days: -10) to get the last week, but still see future dates.

@HannHank Did you find a fix for this?

@Mallington nope, still facing that problem.

@HannHank I have posted a fix here: https://github.com/Mallington/DatePickerTimelineFlutter. You can modify your pubspec.yaml to use:

date_picker_timeline:
      git:
        url: https://github.com/Mallington/DatePickerTimelineFlutter

I'd recommend forking the repository for long term use, just in case I delete it ๐Ÿ˜„

@Mallington thanks ๐Ÿ‘

@HannHank There was an issue with my original commit. I have moved to setting the startDate in the constructor
See Example:

DatePickerTimeline(
   DateTime.now().add(Duration(days: -10)),
         onDateChange: (date) {
           // New date selected
           print(date.day.toString());
         },
         startDate: DateTime.now().add(Duration(days: -10)),
         daysCount: 10,
       )

Hi everyone, this option is now added to the library, just specify the startDate and the calendar will start from that particular date. I have also added a controller to move to any specific date.