zenled / calendar_views

Collection of customisable calendar related widgets for Flutter.
https://pub.dartlang.org/packages/calendar_views
MIT License
102 stars 49 forks source link

JumpToDay using a calendar. #14

Closed AnuragVadd closed 4 years ago

AnuragVadd commented 5 years ago

In my application, I have implemented the daysPageView. I added a showDatePicker widget and i wanted the displayed page to jump to the page which the user selects in the showDatepicker. The widget showDatePicker returns a DateTime variable. But when i tried to call _dayspagecontroller.jumpToDay(), i get this error : The method 'jumpToDay' was called on null. . Could you please help out in modifying the jumpToDay function so that when a DateTime value is returned, The method will jump the page to the selected date in showDatePicker?

The impmentation of jumpToDay in my app : `
_selectDate() async { final DateTime picker =await showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(2010), lastDate: DateTime(2040));

               if (picker != null) {
               setState(() {
                  selectedDate = picker;
                 });
                  Navigator.pop(context);

                 print(selectedDate);

// await runJump(selectedDate); return selectedDate; } } `

`
new FlatButton(onPressed: () => _daysPageController.jumpToDay(_selectDate()), child: Text("change date"),

               ),         

`