Closed murad-alm closed 2 years ago
When you add an event like that and you set it's end time as you did, it lasts for the next 5 years. What you need to do is to add the event 5 times - one event for each year.
Keep in mind, that this library is just a widget, whose task is to display calendar events. But it has no logic in it to calculate repeating events. That is beyond its primary goal. That has to be done in the business logic layer of your app.
When you add an event like that and you set it's end time as you did, it lasts for the next 5 years. What you need to do is to add the event 5 times - one event for each year.
Keep in mind, that this library is just a widget, whose task is to display calendar events. But it has no logic in it to calculate repeating events. That is beyond its primary goal. That has to be done in the business logic layer of your app.
I appreciate your reply!
I think i will do it this way then, or i will figure out a workaround.
Another issue I am facing now is the lag when using the calendar in a combination with a TabBarView
.
When i swipe or tab on another Tab
the device lags for a small while before transitioning to the calendar view.
I have tested the issue on multiple devices/emulators and unfortunately, i couldn't figure out the reason.
Please note that I am using a class that returns a Scaffold
where the calendar is contained.
The TabBarView doesn't save the state of the widgets in it. They are rebuilt every time they reappear on screen.
I used AutomaticKeepAliveClientMixin to keep the Widget "alive"
class CalendarScreen extends StatefulWidget {
@override
State<CalendarScreen> createState() => _CalendarScreenState();
}
class _CalendarScreenState extends State<CalendarScreen> with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Calendar(
startOnMonday: true,
hideTodayIcon: true,
weekDays: const ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
eventsList: _eventList,
isExpandable: false,
eventDoneColor: Colors.green,
selectedColor: Colors.pink,
selectedTodayColor: Colors.red,
todayColor: Colors.blue,
eventColor: null,
// locale: 'de_DE',
// todayButtonText: 'Heute',
// allDayEventText: 'Ganztägig',
// multiDayEndText: 'Ende',
isExpanded: true,
expandableDateFormat: 'EEEE, dd. MMMM yyyy',
datePickerType: DatePickerType.hidden,
dayOfWeekStyle: const TextStyle(
color: Colors.black, fontWeight: FontWeight.w800, fontSize: 11),
),
),
);
}
}
Good Solution. Thank you for your contribution.
Hi, any idea how to repeat certain events at the same date every year? I've tried to do it like this to repeat the event for the next 5 years:
Unfortunately, the event is repeated every day for the next 5 years 😄 Thanks!
Edit: I am aware i can repeat the code 5 times with different years but i want a scalable solution without any hard-coding.