We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set the arbitrary height to appointments in the Flutter event calendar (SfCalendar)

Platform: Flutter |
Control: SfCalendar |
Published Date: January 13, 2021 |
Last Revised Date: January 13, 2021

In the Flutter event calendar, you can set the arbitrary height to the appointment using minimumAppointmentDuration when appointment have a minimum duration.

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
 
void main() => runApp(MinimumAppointmentDuration());
 
class MinimumAppointmentDuration extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
            body: SafeArea(
          child: SfCalendar(
                  view: CalendarView.day,
                  dataSource: getCalendarDataSource(),
                  timeSlotViewSettings: TimeSlotViewSettings(
                      minimumAppointmentDuration: Duration(minutes: 30)),
                ),
 
        )));
  }
 
  _DataSource getCalendarDataSource() {
    final List<Appointment> appointments = <Appointment>[];
    appointments.add(Appointment(
      startTime: DateTime.now().add(const Duration(hours: 1)),
      endTime: DateTime.now().add(const Duration(hours: 2)),
      subject: 'Release Meeting',
      color: Colors.lightBlueAccent,
    ));
    appointments.add(Appointment(
      startTime: DateTime(2021, 1, 6, 9, 30, 0),
      endTime: DateTime(2021, 1, 6, 9, 35, 0),
      subject: 'Performance check',
      color: Colors.amber,
    ));
 
    return _DataSource(appointments);
  }
}
 
class _DataSource extends CalendarDataSource {
  _DataSource(List<Appointment> source) {
    appointments = source;
  }
}

View sample in GitHub

     Without minimum duration

without minimum duration

 

        With minimum duration

with duration

 

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon