iamvivekkaushik/DatePickerTimelineFlutter

Jump to specific date?

Closed this issue · 5 comments

Hey guys,

first we really enjoy your work and love the datepicker timeline.

We are searching for a feature to jump to a specific date.
Example: timeline is on 01.01.2020, users press a button with "12.12.2020" and the timeline jumps to this date immediately.

Do you have any idea or implementation for this?
Would be very helpful for lots of users we think.

Thanks for your attention.

Hi, you can use the controller to jump to any date on the timeline.

First Create a DatePickerController instance.

DatePickerController _controller = DatePickerController();

Set this controller to the DatePicker Widget

DatePicker(
    DateTime.now(),
    width: 60,
    height: 80,
    controller: _controller,
    initialSelectedDate: DateTime.now(),
)

Finally, no the button tap, use the controller to move the timeline to any date.

RaisedButton(
    onPressed: () {
        // This will animate the scroll and move the timeline to the provided date
        _controller. animateToDate(DateTime.now());
    },
)

Hi @iamvivekkaushik need help here.. the animateToDate is working but the date is not highlighted.

video-1621065668.mp4

also how to change the offset so that the selected date will be always on the center

Hi @iamvivekkaushik need help here.. the animateToDate is working but the date is not highlighted.

video-1621065668.mp4

also how to change the offset so that the selected date will be always on the center

AnimateToDate only animates scrolls to a date that you passed. Also there is currently no way for the selected date to be always in center.

@iamvivekkaushik thanks , no worries with the centering.
But how to make the selected date highlighted or isSelected ? when clicking on a specific button.

"DatePickerController is not attached to any DatePicker View" - when calling this animateTo function in initstate!