add_2_calendar icon indicating copy to clipboard operation
add_2_calendar copied to clipboard

Android all day event with same start and end date, end date become before start date

Open MartinJLee opened this issue 3 years ago • 2 comments

I tried to add an all-day event for a day.

final event = Event(
    startDate: eventDate,
    endDate: eventDate,
    title: title,
    allDay: true;
Add2Calendar.addEvent2Cal(event);

This will create an event on android with the start date of the eventDate, end date of the (eventDate -1 day) date. - Tested on Google calendar & Samsun Calendar.

The same call works fine with IOS.

MartinJLee avatar Aug 01 '21 04:08 MartinJLee

Hello, question: what would be the purpose of this scenario?

diegogarciar avatar Aug 10 '21 01:08 diegogarciar

Hello, question: what would be the purpose of this scenario?

The scenario is to add the allDay event.

To solve this problem try this approach. In Dart it will look something like this:

final maybeDate = await showDatePicker(
  context: context,
  initialDate: DateTime.now().add(const Duration(days: 3)),
  firstDate: DateTime.now(),
  lastDate: DateTime(3000),
);

if (maybeDate == null) {
  return;
}

final Event event = Event(
  title: 'Title here',
  startDate: maybeDate,
  endDate: maybeDate.add(const Duration(minutes: 60)),
  allDay: true,
);

await Add2Calendar.addEvent2Cal(event);

I don't know why but it work fine. But in my opinion this is not obviously that you have to add one hour to get allDay event. I think we have to at least write some documentation that will describe how to get allDay event properly. If you would like then I can get deeper into this behaviour and make required PR. Just let me know

mishkov avatar Jan 03 '24 11:01 mishkov