7 C
London
Saturday, March 2, 2024

android – TableCalendar Not Updating State Appropriately


I’ve an inventory, so one thing like

var x = [DateTime(xxxx), DateTime(xxxx)];

And I wish to present customers the times they labored out, so I would like the times in that listing to seem inexperienced, let’s imagine. Nonetheless, once I navigate to a brand new month and generally simply navigate in any respect, the inexperienced circle disappears. I do know my operate is used appropriately, as a result of the font measurement differs from the default textual content, however it would not present the circle. I included photos of the problem and the code for the calendar is linked under. Thanks!

                           Container(
                              width: measurement.width * .9,
                              little one: TableCalendar(
                                firstDay: DateTime.utc(1900, 10, 16),
                                lastDay: DateTime.utc(2200, 3, 14),
                                availableGestures:
                                    AvailableGestures.horizontalSwipe,
                                focusedDay: _focusedDay,
                                calendarFormat: _calendarFormat,
                                selectedDayPredicate: (day) {
                                  return isSameDay(_selectedDay, day);
                                },
                                key: _calendarKey,
                                daysOfWeekStyle: DaysOfWeekStyle(
                                    weekdayStyle: TextStyle(
                                        coloration: AppColors(theme).secondaryText),
                                    weekendStyle: TextStyle(
                                        coloration: AppColors(theme).secondaryText)),
                                calendarStyle: CalendarStyle(
                                    selectedDecoration: BoxDecoration(
                                        coloration: AppColors(theme).darkGreen,
                                        form: BoxShape.circle),
                                    isTodayHighlighted: false,
                                    todayTextStyle: TextStyle(
                                      coloration: AppColors(theme).primaryText,
                                    ),
                                    defaultTextStyle: TextStyle(
                                        coloration: AppColors(theme).primaryText,
                                        fontSize: 20),
                                    weekendTextStyle: TextStyle(
                                        coloration: AppColors(theme).primaryText,
                                        fontSize: 20),
                                    outsideTextStyle: TextStyle(
                                        coloration: AppColors(theme).primaryText),
                                    outsideDecoration: BoxDecoration(
                                      form: BoxShape.circle,
                                    )),
                                onDaySelected: (selectedDay, focusedDay) {
                                  setState(() {
                                    _selectedDay = selectedDay;
                                    _focusedDay = focusedDay;
                                    sortExercises();
                                  });
                                },
                                
                                calendarBuilders: CalendarBuilders(
                                    defaultBuilder: (context, day, focusedDay) {
                                  bool workedOut = worked_out_days.any(
                                      (workedOutDay) =>
                                          isSameDay(workedOutDay, day));
                                  return workedOut
                                      ? Container(
                                          margin: const EdgeInsets.all(4.0),
                                          ornament: BoxDecoration(
                                            coloration: AppColors(theme).footerGrey,
                                            form: BoxShape.circle,
                                          ),
                                          little one: Heart(
                                            little one: Textual content(
                                              '${day.day}',
                                              model: TextStyle(
                                                coloration: AppColors(theme)
                                                    .primaryText,
                                              ),
                                            ),
                                          ),
                                        )
                                      : null;
                                }),
                                headerStyle: HeaderStyle(
                                    leftChevronVisible: false,
                                    rightChevronVisible: false,
                                    formatButtonVisible: false,
                                    titleCentered: true,
                                    headerMargin: EdgeInsets.solely(backside: 15),
                                    titleTextStyle: TextStyle(
                                        coloration: AppColors(theme).primaryText,
                                        fontSize: 20)),
                                onPageChanged: (focusedDay) {
                                  setState(() {
                                    _focusedDay = focusedDay;
                                  });
                                },
                              ))

You possibly can see within the picture the 25, 26, 27, 28, and 29 for feb is chosen (with a gray circle), however once I go to march, only one and a pair of are chosen, not 25, 26, 27, 28, and 29.

enter image description here

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here