I have a scheduling application which shows a calendar in the timelineDay view with resources. My app will only display this calendar for a single day, with the times the business is open (minDate 8:00am, maxdate 8:00pm or something similar).
By default, the calendar header contains two lines, the first being the month/year ("July 2022") followed by another line with the day ("27 Wednesday"). In my case, this is a huge waste of space. I'd like to customize it to one short line with the date, something like "Wed. 6/27".
Can this be done? I only see custom builders for the schedule view.
Hi George,
Regarding Query: the calendar header contains two lines, the first being the month/year ("July 2022") followed by another line with the day ("27 Wednesday"). In my case, this is a huge waste of space. I'd like to customize it to one short line with the date.
By hiding the default headers (headerHeight and viewHeaderHeight value as 0) and adding the required widget you can achieve this requirement. Also, we have KB documentation for custom headers in Flutter calendar. Please find the documentation from the following link.
KB link:
https://www.syncfusion.com/kb/10997/how-to-add-custom-header-and-view-header-in-the-flutter-calendar
Also, we have UG documentation for the same. Please find the documentation for the same.
UG link:
https://help.syncfusion.com/flutter/calendar/headers#customize-header-height-in-calendar
https://help.syncfusion.com/flutter/calendar/headers#customize-view-header-height-in-calendar
We hope that this helps you. Please let us know if you need further assistance.
Regards,
Indumathi R
Thanks - that does work, but it causes (or exposes) another problem. Now when I display this view in landscape orientation, and the contents don't fit, I get an overflow on the bottom of 30 pixels, which is the height of my new header container (see below). Also note that my SfCalendar isn't using all of the page area that it can when it portrait mode. It's only using about half the page (also see below. I am also including my flutter widget code. I've been trying to wrap the calendar and its enclosing containers in an Expanded widget, but this doesn't help. Please advise.
landscape mode with overflow:
portrait mode only showing 3 of 19 resources:
Flutter page/widget code:
_calendar = SfCalendar(
minDate: dtStart,
maxDate: dtEnd,
initialDisplayDate: DateTime.now(),
timeSlotViewSettings: const TimeSlotViewSettings(
timeInterval: Duration(minutes: 30),
timeFormat: "h:mm a",
),
headerHeight: 0,
viewHeaderHeight: 0,
view: CalendarView.timelineDay,
dataSource: _CourtSheetDataSource(facilitySchedule[0].items, resources),
resourceViewHeaderBuilder: resourceBuilder,
// resourceViewSettings: const ResourceViewSettings(
// displayNameTextStyle: TextStyle(color: Colors.white),
// showAvatar: false,
// size: 120,
// visibleResourceCount: 15),
onTap: onCalendarTap,
);
return FutureBuilder<bool>(
future: initialize(),
builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.hasData) {
return SafeArea(
child: PlatformScaffold(
appBar: PlatformAppBar(
leading: PlatformIconButton(
cupertinoIcon: const Icon(Icons.arrow_back_ios),
materialIcon: const Icon(Icons.arrow_back),
onPressed: () => Navigator.pop(context)),
title: const Text("Court Sheets")),
body: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
//color: const Color(0xFFFFFFFF),
height: 40,
child: Center(
child: Text(DateFormat("yMMMMEEEEd").format(widget.date),
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 16, /*color: Colors.blue*/
)),
),
),
),
],
),
Row(children: [Expanded(child: Container(child: _calendar))])
],
),
));
} else {
return const Center(
child: SizedBox(height: 100.0, width: 100.0, child: CircularProgressIndicator()));
}
});
}
Hi George,
We have prepared the simple sample for “Custom header with resource view in Flutter Calendartimeline views” and there is no overflow issue and we have placed the calendar inside the Expanded widget, it was working fine in Portrait and Landscape mode. We have attached the tested sample for the same. Please find the sample from the following link.
Sample link:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/resourceheader1974844169.zip
Please check the sample and let us know if you still facing the same issue? If not, please modify the sample based on your scenario and revert us back with the following details. It will be helpful for us to check on it and provide you the solution at the earliest.
Regards,
Indumathi R
Thanks very much. I see you used the Expanded Widget which didn't work for me for some reason. In any case, I solved the problem late last night by:
Worked nicely (see below). Thanks for your assistance. You can close this issue.
Hi George,
We are happy to hear that the problem has been resolved by yourself. Please let us know if you have any other concerns. As always, we will gladly assist you.
Regards,
Indumathi R
how can you achieve that line in between the resources timeline ???
How can we do that grey line under "book it"?
Alfredo,
To achieve your requirement in the Flutter Calendar, you can use the Appointment Builder and TimeRegion Builder supports. These supports allow you to customize the appearance of appointments and time regions in the calendar, respectively.
You can refer to our UG documentation to learn more about Appointment Builder and TimeRegion Builder in the Calendar. We have included the links below for your convenience:
https://help.syncfusion.com/flutter/calendar/builders#appointment-builder
https://help.syncfusion.com/flutter/calendar/builders#time-region-builder
Additionally, you can also refer to our UG documentation for more information about resource view. We have included the link below for your convenience:
https://help.syncfusion.com/flutter/calendar/resource-view
To further assist you, you can explore the Flutter Calendar SampleBrowser demo and sample from the link below:
https://flutter.syncfusion.com/#/event-calendar/resource-view
I hope this information helps. Let me know if you have any further questions or concerns.