Coder Social home page Coder Social logo

stef-gms / add_2_calendar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ja2375/add_2_calendar

0.0 0.0 0.0 169 KB

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

License: MIT License

Ruby 9.52% Objective-C 3.09% Kotlin 24.55% Dart 34.05% Swift 28.79%

add_2_calendar's Introduction

add_2_calendar

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. A element must be added to your manifest as a child of the root element. See the Android documentation for examples of other queries.

<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 interval, ocurrances 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 diffrent 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>

Note: See DateTime docs to know what valid date could be correct in above piece of code.

Example

Please run the app in the example/ folder to start playing!

add_2_calendar's People

Contributors

aaumond avatar diegog-sf avatar diegogarciar avatar furkankurt avatar inventrohyder avatar ja2375 avatar javadi69 avatar joakimhew avatar kiruel avatar maleandr avatar martin-geidobler avatar mnomanmemon avatar nilsreichardt avatar palmsnipe avatar return9912 avatar scholliyt avatar thomassth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.