flutter_calendar_view icon indicating copy to clipboard operation
flutter_calendar_view copied to clipboard

Weekview shows multi day events incorrect

Open rickdijk opened this issue 3 years ago • 10 comments

I have an event created for multiple days with for example starttime 1pm on Saturday and endtime 2pm on the Monday after.

Code:

(
          event: booking,
          title: StringExtensions.toInitials(
            booking.user!.firstName,
            booking.user!.lastName,
          ),
          date: booking.startDateTime,
          startTime: booking.startDateTime,
          endTime: booking.endDateTime,
          endDate: booking.endDateTime,
          color: Color.fromARGB(255, 227, 83, 76),
)

It shows up like this: image image

What am I missing?

rickdijk avatar Dec 10 '21 12:12 rickdijk

Hello @rickdijk, as for current implementation it is the expected behaviour. As of now in multiple day events, startTime and endTime is being considered as timespan over a single date.

So, In this case it will display event tile with 1 hr timespan (1pm - 2pm) from saturday to monday.

PRBaraiya avatar Mar 07 '22 08:03 PRBaraiya

With version 0.0.4 it multiday events doesn't work (WeekView) Here is my code:

return CalendarEventData<Schedule>(
      color: AppColors.availabilityGreen.withOpacity(0.2),
      title: DateFormatter.formatTime(schedule.start).toLowerCase(),
      date: schedule.start,
      startTime: schedule.start,
      endTime: schedule.end,
      event: schedule,
    );

Here is an error:

Assertion fail for event: 
{date: 2022-04-05 13:00:00.000Z, startTime: 2022-04-05 13:00:00.000Z, endTime: 2022-04-06 12:00:00.000Z, event: Schedule(35736, ScheduleRepeat(438, 1264, [], 2022-04-05 14:25:23.787389, 2022-04-05 14:25:23.787389), false, 2022-04-05 13:00:00.000Z, 2022-04-06 12:00:00.000Z), title: 1:00 pm, description: , endDate: 2022-04-05 13:00:00.000Z}
startDate must be less than endDate.
This error occurs when you does not provide startDate or endDate in CalendarEventDate or provided endDate occurs before startDate.
'package:calendar_view[/src/event_arrangers/side_event_arranger.dart]()':
package:calendar_view/…/event_arrangers/side_event_arranger.dart:1
Failed assertion: line 130 pos 11: '!(endTime.getTotalMinutes <= startTime.getTotalMinutes)'

What I missed?

vradchuk avatar Apr 05 '22 11:04 vradchuk

@vradchuk Here, you are providing startTime as 13:00 and endTime as 12:00. That's causing the problem.

Note that in startTime and endTime only time is being considered. so, In your case endTime(12:00) will occur before startTime(13:00) that's why it is throwing assertion.

PRBaraiya avatar Apr 05 '22 11:04 PRBaraiya

@PRBaraiya Yes, the endTime is less than startTime. But endTime is tomorrow. How can I set the event that starts, for example, 2022-04-05 14:00 and ends 2022-04-06 10:00? Is it possible with the current WeekView implementation?

vradchuk avatar Apr 05 '22 11:04 vradchuk

@vradchuk No, as of not it does not support that functionality by default. But if you want you can implement EventArranger in your code. and provide it as eventArranger argument.

EvenrArranger defines how an event will be displayed based on timespan in DayView and WeekView.

here you can find more about it

PRBaraiya avatar Apr 05 '22 11:04 PRBaraiya

@PRBaraiya I thought about EventAranger, but it's not suitable in my case. So, I decided to split up multi-day events into single ones. Thanks for help.

vradchuk avatar Apr 05 '22 12:04 vradchuk

how did you split the multiday event?

edoliantesjr avatar Aug 17 '22 18:08 edoliantesjr

image how can u select the day in the timeline? (sorry about asking this in a different issue)

Saliim17 avatar Jan 13 '23 19:01 Saliim17

Similar issue #220

ParthBaraiya avatar May 06 '23 18:05 ParthBaraiya

The solution for the moment is to break events that span more than a day into multiple events.

dkobia avatar Nov 23 '23 01:11 dkobia