I have a Flutter app that runs on Android, iOS, and web.
One of the features is that a user can enter a date and time and it adds it to a calendar. This works great on Android and I am assuming iOS but it does not work on the web/browser.
I am using the add_2_calendar widget. How do I get this to work on the web/browser?
Here is the code:
import 'package:add_2_calendar/add_2_calendar.dart';
import 'package:deal_diligence/Providers/event_provider.dart';
class AddEventsToAllCalendars {
static void addEvent(Events event) {
Add2Calendar.addEvent2Cal(buildEvent(event));
}
static Event buildEvent(Events event) {
Frequency freq = Frequency.yearly;
if (event.frequency != "" && event.frequency != null) {
if (event.frequency == 'daily') {
freq = Frequency.daily;
} else if (event.frequency == 'weekly') {
freq = Frequency.weekly;
} else if (event.frequency == 'monthly') {
freq = Frequency.monthly;
}
}
if (event.eventDuration == "" || event.eventDuration == null) {
event.eventDuration = "30";
}
return Event(
title: event.eventName!,
description: event.eventDescription,
location: event.location,
startDate: event.eventDate!,
endDate: event.eventStartTime!
.add(Duration(minutes: int.parse(event.eventDuration!))),
allDay: event.allDay,
// iosParams: const IOSParams(
// reminder: Duration(minutes: 40),
// url: "http://example.com",
// ),
androidParams: const AndroidParams(
emailInvites: ["[email protected]"],
),
recurrence: Recurrence(
frequency: freq,
endDate: event.recurrenceEndDate,
),
);
}
}