add_2_calendar 2.2.3

flutter, calendar, event, software

A really simple Flutter plugin to add events to each platform's default calendar.

Installation #

In your pubspec.yaml file within your Flutter Project:

dependencies:
  add_2_calendar: ^2.1.2

Android integration 

The plugin doesn't need any special permissions by default to add events to the calendar. However, events can also be added without launching the calendar application, for this it is needed to add calendar permissions to your AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_CALENDAR" />

Starting from API 30 Android requires package visibility configuration in your AndroidManifest.xml

<queries>
  <intent>
    <action android:name="android.intent.action.INSERT" />
    <data android:mimeType="vnd.android.cursor.item/event" />
  </intent>
</queries>

iOS integration 

In order to make this plugin work on iOS 10+, be sure to add this to your info.plist file:

<key>NSCalendarsUsageDescription</key>
<string>INSERT_REASON_HERE</string>

NSContactsUsageDescription is required for the location autocomplete once Apple's UI is opened, so it is highly recommended that you also add the key, the app might crash otherwise.

<key>NSContactsUsageDescription</key>
<string>INSERT_REASON_HERE</string>

Use it 

import 'package:add_2_calendar/add_2_calendar.dart';

final Event event = Event(
      title: 'Event title',
      description: 'Event description',
      location: 'Event location',
      startDate: DateTime(/* Some date here */),
      endDate: DateTime(/* Some date here */),
      iosParams: IOSParams( 
        reminder: Duration(/* Ex. hours:1 */), // on iOS, you can set alarm notification after your event.
        url: 'https://www.example.com', // on iOS, you can set url to your event.
      ),
      androidParams: AndroidParams( 
        emailInvites: [], // on Android, you can add invite emails to your event.
      ),
    );
...
Add2Calendar.addEvent2Cal(event);
...

This will launch the default calendar application to confirm the event and add it to your calendar.

Recurring events 

You can add recurrency to your events by specifying a frequency. Optional parameters such as intervalocurrances and endDate can also be added.

Event(
   ...
  recurrence: Recurrence(
        frequency: Frequency.monthly,
        interval: 2,
        ocurrences: 6,
      ),
    );

iOS language support

By default the ios screen that appears to save the event will be displayed in English, to support different languages, add to your info.plist the languages you are supporting.

<key>CFBundleLocalizations</key>
	<array>
		<string>en</string>
		<string>es</string>
		<string>ja</string>
	</array>

 

Disclaimer: The content on this website is for general information purposes only. While we strive to provide accurate and up-to-date information, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability, or availability of the content. Some content, including images, videos, and articles, may be owned by third parties and are used on this website with permission or under applicable copyright laws. We do not claim ownership of any content that is not explicitly marked as ours. Any reliance you place on the content is therefore strictly at your own risk. In no event will we be liable for any loss or damage arising from your use of this website or its content.

Interested in hiring us for your project?

To start an initial chat, just drop an email at mail@foozawebtech.com or use the form on the contact page.