iamvivekkaushik / DatePickerTimelineFlutter

Flutter Date Picker Library that provides a calendar as a horizontal timeline
Apache License 2.0
283 stars 198 forks source link

Jump to specific date? #40

Closed chschroe closed 3 years ago

chschroe commented 3 years ago

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.

iamvivekkaushik commented 3 years ago

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());
    },
)
william-levi commented 3 years ago

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

https://user-images.githubusercontent.com/25534399/118352982-f2e8d880-b596-11eb-8806-7328ed35a777.mp4

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

iamvivekkaushik commented 3 years ago

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

https://user-images.githubusercontent.com/25534399/118352982-f2e8d880-b596-11eb-8806-7328ed35a777.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.

william-levi commented 3 years ago

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

developerflutter commented 3 years ago

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