1

I am using DatePicker from package:date_picker_timeline

here I want to set start date:-30 days of current date and end date: +30 days of current date

and It should be shown current date when I start app..I mean showing today date and I can be able to move and forward upto 30 days

I am failing to finding regarding properties, and it should be shown current date with selected when app starts...

DateTime.now(),
                initialSelectedDate:DateTime.now(),
                selectionColor: Colors.blue,
                monthTextStyle: TextStyle(fontSize: 12),
                onDateChange: (DateTime date) {
                  setState(() {
                    selecteddate = date;
                    //print("Selected Date is :"+selecteddate.toString());
                  });
                },
              ),

1 Answer 1

1

You can take help from activeDates parameter,

DatePicker(
  DateTime.now().subtract(Duration(days: 30)),
  activeDates: List.generate(
      60,
      (index) => (DateTime.now().subtract(Duration(days: 30)))
          .add(Duration(days: index))),
  initialSelectedDate: DateTime.now(),
  selectionColor: Colors.black,
  selectedTextColor: Colors.white,
  onDateChange: (date) {},
),
Sign up to request clarification or add additional context in comments.

7 Comments

but its not showing previous 30 dates....
Sorry, didn't notice that. updated
here I want to implement one more thing, but recently u said that it need scroll otherwise not possible
here while giving activate dates -30 to +30 , its working but to move to current date I have to scroll upto that today date.. is there any option that shows current date on start and we can have choice to move +30 and -30
You can add a controller and animate to the index after first frame is build. the package last update was 16th months ago, need some support I think
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.