rwbr / flutter_neat_and_clean_calendar

Simple and clean flutter calendar with ability to slide up/down to show weekly/monthly calendar. Forked from [flutter_clean_calender](https://pub.dev/packages/flutter_clean_calendar)
MIT License
104 stars 51 forks source link

Updated events are not reflected on Calendar #37

Closed aniket-github closed 2 years ago

aniket-github commented 2 years ago
@override
  Widget build(BuildContext context) {
    print('build, _eventList:${_eventList.length}');
    return Scaffold(
      body: SafeArea(
        child: Calendar(
          startOnMonday: true,
          weekDays: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
          eventsList: _eventList,
          isExpandable: true,
          eventDoneColor: Colors.green,
          selectedColor: Colors.pink,
          selectedTodayColor: Colors.green,
          todayColor: Colors.blue,
          eventColor: null,
          locale: 'de_DE',
          todayButtonText: 'Heute',
          allDayEventText: 'Ganztägig',
          multiDayEndText: 'Ende',
          isExpanded: true,
          expandableDateFormat: 'EEEE, dd. MMMM yyyy',
          datePickerType: DatePickerType.date,
          onMonthChanged: (dateTime) => getShipments(dateTime),
          dayOfWeekStyle: TextStyle(
              color: Colors.black, fontWeight: FontWeight.w800, fontSize: 11),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {},
        child: const Icon(Icons.add),
        backgroundColor: Colors.green,
      ),
    );
  }
updateEvent(dateTime){
// **NOTE: add event from last month or next month**
    setState(() {
      _eventList = [
        NeatCleanCalendarEvent('MultiDay Event Acccccc',
            startTime: DateTime(DateTime.now().year, DateTime.now().month,
                DateTime.now().day, 15, 0),
            endTime: DateTime(DateTime.now().year, DateTime.now().month,
                DateTime.now().day + 2, 18, 0),
            color: Colors.yellow,
            isMultiDay: true),
        NeatCleanCalendarEvent('Allday Event Bcccccc',
            startTime: DateTime(DateTime.now().year, DateTime.now().month,
                DateTime.now().day - 12, 14, 30),
            endTime: DateTime(DateTime.now().year, DateTime.now().month,
                DateTime.now().day  - 12, 17, 0),
            color: Colors.yellow,
            isAllDay: true),
      ];
      print('update _eventList:${_eventList.length}');
    });
}
aniket-github commented 2 years ago

by using this code, try to change the month it will update _eventList with new events. it should display events on the calendar but events are shown that were passed the first time.

aniket-github commented 2 years ago

@rwbr

rwbr commented 2 years ago

What does the line

print('build, _eventList:${_eventList.length}');

print out after setState() was called? Does _eventList have the expected content?