Skip to content

[syncfusion_flutter_calendar] Appointment drag-and-drop snaps to incorrect start time when view is non-scrollable (timeIntervalHeight: -1) #2549

Description

@WieFel

Bug description

When the SfCalendar is configured with a non-scrollable time-slot view (e.g., using timeIntervalHeight: -1 to auto-fit the screen or using a small manual height), dragging an appointment to a late hour causes the start time to "snap" back to an earlier time.

For example, dragging a 3-hour appointment to start at 22:00 (which would end at 01:00 the next day) results in the appointment being forced to start at 21:00 (or a jittery time like 21:05 depending on resolution) so that it ends exactly at 24:00.

Steps to reproduce

  1. Initialize SfCalendar with view: CalendarView.day (or week/workWeek).
  2. Set timeSlotViewSettings: const TimeSlotViewSettings(timeIntervalHeight: -1).
  3. Create an appointment with a duration of 3 hours.
  4. Enable drag-and-drop (allowDragAndDrop: true).
  5. Attempt to drag the appointment to start at 10:00 PM (22:00).
  6. Observe that the calendar prevents the move to 22:00 and instead forces the appointment to an earlier start time to ensure it doesn't "overflow" the visible day area.

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';

void main() {
  return runApp(
    const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(body: SafeArea(child: CalendarDragDrop())),
    ),
  );
}

class CalendarDragDrop extends StatelessWidget {
  const CalendarDragDrop({super.key});

  @override
  Widget build(BuildContext context) {
    return SfCalendar(
      view: CalendarView.week,
      allowDragAndDrop: true,
      timeSlotViewSettings: const TimeSlotViewSettings(timeIntervalHeight: -1),
      dataSource: _AppointmentDataSource(_getDataSource()),
      appointmentBuilder: (context, details) {
        final Appointment appointment = details.appointments.first;

        return Container(
          decoration: BoxDecoration(
            color: appointment.color,
            borderRadius: BorderRadius.circular(4),
          ),
          padding: const EdgeInsets.all(4),
          child: Text(
            '${appointment.subject}\n'
            '${TimeOfDay.fromDateTime(appointment.startTime).format(context)} - ${TimeOfDay.fromDateTime(appointment.endTime).format(context)}',
            style: const TextStyle(color: Colors.white, fontSize: 12),
          ),
        );
      },
    );
  }

  List<Appointment> _getDataSource() {
    final DateTime today = DateTime.now();
    return <Appointment>[
      Appointment(
        startTime: DateTime(today.year, today.month, today.day, 9),
        endTime: DateTime(today.year, today.month, today.day, 12),
        subject: 'Drag me!',
        color: Colors.blue,
      ),
    ];
  }
}

/// Simple data source to provide appointment data to the calendar
class _AppointmentDataSource extends CalendarDataSource {
  _AppointmentDataSource(List<Appointment> source) {
    appointments = source;
  }
}

Screenshots or Video

Screenshots / Video demonstration Image

Stack Traces

Stack Traces
doesn't apply here

On which target platforms have you observed this bug?

Web

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.44.2, on macOS 26.5.2 25F84 darwin-arm64, locale en-IT) [669ms]
    • Flutter version 3.44.2 on channel stable at /Users/work/fvm/versions/3.44.2
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c9a6c48423 (6 weeks ago), 2026-06-10 15:52:41 -0700
    • Engine revision 77e2e94772
    • Dart version 3.12.2
    • DevTools version 2.57.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop,
      enable-android, enable-ios, cli-animations, enable-native-assets, enable-swift-package-manager,
      omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,585ms]
    • Android SDK at /Users/Shared/Android/sdk
    • Emulator version 36.6.11.0 (build_id 15507667) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • ANDROID_HOME = /Users/Shared/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.10+-117844308-b1163.108)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.5) [964ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17F42
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [6ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (4 available) [6.1s]
    (removed)

[✓] Network resources [282ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcalendarCalendar componentfollow-up scheduledFollow-up scheduled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions