resourceIds property
The ids of the CalendarResource that shares this TimeRegion.
Based on this Id the TimeRegions are grouped and arranged to each resource in calendar view.
See also:
- CalendarResource, object which contains the resource data.
- ResourceViewSettings, the settings have properties which allow to customize the resource view of the SfCalendar.
- CalendarResource.id, the unique id for the CalendarResource view of SfCalendar.
- CalendarDataSource, which used to set the resources collection to the calendar.
- Knowledge base: How to add resources
@override
Widget build(BuildContext context) {
return Container(
child: SfCalendar(
view: CalendarView.timelineMonth,
dataSource: _getCalendarDataSource(),
specialRegions: _getTimeRegions(),
),
);
}
}
class DataSource extends CalendarDataSource {
DataSource(List<Appointment> source,
List<CalendarResource> resourceColl) {
appointments = source;
resources = resourceColl;
}
}
DataSource _getCalendarDataSource() {
List<Appointment> appointments = <Appointment>[];
List<CalendarResource> resources = <CalendarResource>[];
appointments.add(Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(Duration(hours: 2)),
isAllDay: true,
subject: 'Meeting',
color: Colors.blue,
resourceIds: <Object>['0001'],
startTimeZone: '',
endTimeZone: ''));
resources.add(
CalendarResource(displayName: 'John', id: '0001',
color: Colors.red));
return DataSource(appointments, resources);
}
List<TimeRegion> _getTimeRegions() {
final List<TimeRegion> regions = <TimeRegion>[];
regions.add(TimeRegion(
startTime: DateTime.now(),
endTime: DateTime.now().add(Duration(hours: 1)),
enablePointerInteraction: false,
color: Colors.grey.withOpacity(0.2),
resourceIds: <Object>['0001'],
text: 'Break'));
return regions;
}
Implementation
final List<Object>? resourceIds;