iamvivekkaushik / DatePickerTimelineFlutter

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

Show dates in reverse order #67

Closed ajinzrathod closed 2 years ago

ajinzrathod commented 2 years ago

This is my code

child: DatePicker(
                DateTime.now().subtract(Duration(days: 5)),
                initialSelectedDate: DateTime.now(),
                selectionColor: Colors.black,
                selectedTextColor: Colors.white,
                daysCount: 6,
                onDateChange: (date) {
                  // New date selected
                }
            )

This code shows me Dates from April 1st to April 6th, But what I want is to see dates in reverse order,

April 6 must be displayed first and then 5, 4, 3, 2, 1

ajinzrathod commented 2 years ago

If my pull request is not accepted, you can see how to reverse the days in this commit

https://github.com/ajinzrathod/DatePickerTimelineFlutter/commit/b0ad1ed32ac22c674d86a6f1224e253d3013ef1b

After changing the actual library file, do this,

child: DatePicker(
                DateTime.now().subtract(Duration(days: 5)),
                initialSelectedDate: DateTime.now(),
                selectionColor: Colors.black,
                selectedTextColor: Colors.white,
                daysCount: 6,
                onDateChange: (date) {
                  // New date selected
                }
                reverseDays = true, // <-------------- Add this line
            )

and it will show dates in reverse order