iamvivekkaushik / DatePickerTimelineFlutter

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

JumpToSelection() offset has issues. #29

Closed amith-patil closed 3 years ago

amith-patil commented 4 years ago

Describe the bug

the JumpToSelection() function takes the time into consideration causing offset values to change during different times.

To Reproduce

Create a startDate to be of the format "YYYY-MM-DD 00:00:00" select initialSelectedDate as DateTime.now() over the course of the day, on calling the JumpToSelection() for the first time via a separate button, the timeline will jump from to the date +1 value ( ex: if today is may 11th, JumpToSelection() will jump to May 12th after a period of the day has passed)

Expected behavior

A clear and concise description of what you expected to happen. on initial jump, the timeline should jump to the initialSelectedDate Value

Screenshots

If applicable, add screenshots to help explain your problem.

ezgif-3-d1001ca39879

also, this weird thing happens, I'm not sure why :

ezgif-3-3c6cb3f8f3af

Additional context Add any other context about the problem here.

code used by me :


  DateTime _selectedDate = DateTime.now();
.
.
.
DatePickerController _dpc = new DatePickerController();
.
.
.
DatePicker(
                          _startDate,
                          controller: _dpc,
                          initialSelectedDate: _selectedDate,
                          width: Size_Config.blockSizeHorizontal * 15,
                          height: Size_Config.blockSizeVertical * 12,
                          monthTextStyle: TextStyle(
                              fontFamily: 'Montserrat',
                              color: Colors.white54,
                              fontSize: Size_Config.blockSizeHorizontal * 3),
                          dateTextStyle: TextStyle(
                              fontFamily: 'MontSerrat',
                              fontSize: Size_Config.blockSizeHorizontal * 5,
                              fontWeight: FontWeight.bold,
                              color: Colors.white54),
                          dayTextStyle: TextStyle(
                              fontFamily: 'Montserrat',
                              color: Colors.white54,
                              fontSize: Size_Config.blockSizeHorizontal * 3),
                          onDateChange: (date) {
                            _pc.open();
                            setState(() {
                              _selectedDate = date;
                            });
                          },
                        ),
.
.
.
IconButton(
                                  onPressed: () {
                                    _dpc.animateToSelection();
                                  },
                                  icon: Icon(CustomIcons.filter),
                                  color: Colors.white54,
                                  //iconSize: 40,
                                ),
iamvivekkaushik commented 4 years ago

Hi Amith, can you remove the width argument from the DatePicker widget and check if you still have this issue.

amith-patil commented 4 years ago

Hi Amith, can you remove the width argument from the DatePicker widget and check if you still have this issue.

I removed the width for the datepicker widget and I still see the problem,

So yesterday night around 1 am when I was working on it, it showed the correct date jump, now it's showing the 13th instead of the 12th. you can repro this by changing the date of the phone .

amith-patil commented 4 years ago

I think it's got something to do with the timestamp on the _currentDate item.

iamvivekkaushik commented 4 years ago

Okay, thanks for the insight.

iamvivekkaushik commented 3 years ago

Hi @amith-patil, I've fixed the issue you were facing and released a new version. I am closing this issue.