resourceViewHeaderBuilder property Null safety

ResourceViewHeaderBuilder? resourceViewHeaderBuilder
final

Defines the builder that builds a widget and replaces the header view of resource in SfCalendar.

Defaults to null.

see also:

  • resourceViewSettings, to customize the resource view in the calendar
  • CalendarResource, the object which holds the data of the resource in calendar.
  • dataSource.resources, the collection of resource to be displayed in the timeline views of SfCalendar.
Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: Text('Calendar'),
      ),
      body: SfCalendar(
          view: CalendarView.timelineMonth,
          resourceViewHeaderBuilder:
              (BuildContext context, ResourceViewHeaderDetails details) {
            if (details.resource.image != null) {
              return Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisSize: MainAxisSize.max,
                children: [
                  CircleAvatar(backgroundColor: details.resource.image),
                  Text(details.resource.displayName)
                ],
              );
            } else {
              return Container(
                color: details.resource.color,
                child: Text(
                    details.resource.displayName
                ),
              );
            }
          }),
    ),
  );
}

Implementation

final ResourceViewHeaderBuilder? resourceViewHeaderBuilder;