Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar random error #599

Closed
Ankit0080 opened this issue Oct 12, 2021 · 1 comment
Closed

Calendar random error #599

Ankit0080 opened this issue Oct 12, 2021 · 1 comment

Comments

@Ankit0080
Copy link

Ankit0080 commented Oct 12, 2021

This code was working fine suddenly In release mode the calendar screen is blank and in debug mode it's working

@OverRide
void initState() {
_focusedDay = DateTime.now();
super.initState();

}

TableCalendar(
firstDay:
DateTime.utc(_startYear, _startMonth, _startDate),
lastDay: DateTime.utc(_endYear, _endMonth, _endDate),
focusedDay: _focusedDay,
rowHeight: 45,
calendarFormat: _calendarFormat,
startingDayOfWeek: StartingDayOfWeek.monday,
selectedDayPredicate: (day) {
return isSameDay(_selectedDay, day);
},
onDaySelected: (selectedDay, focusedDay) {
print("selected date is " + selectedDay.toString());
var dayOfWeek = DateFormat.EEEE().format(selectedDay);
// widget.foodDateSelectionCallback.onFoodDateSelected(
// selectedDay.toString().split(" ")[0], dayOfWeek);
// Navigator.pop(context);

                    if (!isSameDay(_selectedDay, selectedDay)) {
                      setState(() {
                        _selectedDay = selectedDay;
                        _focusedDay = focusedDay;
                      });
                    }
                  },
                  onPageChanged: (focusedDay) {
                    _focusedDay = focusedDay;
                    presentMonth = focusedDay.month.toString();
                    getCalendarEvents();
                    //Helper.showToast(presentMonth);
                  },
                  locale: 'en_US',
                  calendarStyle: CalendarStyle(
                      outsideDaysVisible: false,
                      weekendTextStyle: TextStyle(
                          color: Colors.red,
                          fontFamily: 'PoppinsMedium',
                          fontSize: AppFontSize.font_medium),
                      defaultTextStyle: TextStyle(
                          color: Colors.black,
                          fontFamily: 'PoppinsMedium',
                          fontSize: AppFontSize.font_medium)),
                  daysOfWeekStyle: DaysOfWeekStyle(
                    weekendStyle: TextStyle(
                        color: Colors.black,
                        fontFamily: 'PoppinsMedium',
                        fontSize: AppFontSize.font_medium),
                    weekdayStyle: TextStyle(
                        color: Colors.black,
                        fontFamily: 'PoppinsMedium',
                        fontSize: AppFontSize.font_medium),
                  ),
                  headerStyle: HeaderStyle(
                      titleCentered: true,
                      formatButtonVisible: false,
                      titleTextStyle: TextStyle(
                          color: Colors.black,
                          fontFamily: 'PoppinsMedium',
                          fontSize: AppFontSize.font_medium)),
                ),
@aleksanderwozniak
Copy link
Owner

error isSameDat(focusday,lastday)|| focusday.isBefore(lastDay) is not true

Looks like your _focusedDay is after your lastDay. It has to be between the firstDay and the lastDay in order for the widget to work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants