Category / Section
How to exclude the dates from recurrence appointments in the Flutter Calendar?
In the Flutter Event Calendar, you can exclude the specific occurrences from a recurring appointment by using the recurrenceExceptionDates property of the Appointment class.
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
void main() => runApp(RecurrenceException());
class RecurrenceException extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: SafeArea(
child: SfCalendar(
view: CalendarView.week,
dataSource: _getCalendarDataSource(),
),
),
),
);
}
_AppointmentDataSource _getCalendarDataSource() {
List<Appointment> appointments = <Appointment>[];
DateTime exceptionDate = DateTime(2020, 12, 23);
appointments.add(Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(Duration(hours: 1)),
subject: 'Meeting',
color: Colors.pink,
recurrenceRule:
'FREQ=DAILY;COUNT=20',
recurrenceExceptionDates: <DateTime>[exceptionDate]));
)
);
return
_AppointmentDataSource
(
appointments
);
}
}
class _AppointmentDataSource extends CalendarDataSource {
_AppointmentDataSource(List<Appointment> source) {
appointments = source;
}
}
|
