A cross platform plugin for modifying calendars on the user's device

Overview

Device Calendar Plugin

If you're upgrading to v4.0.0, your previous code will need to be modified (slightly) otherwise it will not run after update. See Timezone support for more details.

pub package Pub Version (including pre-releases) build

A cross platform plugin for modifying calendars on the user's device.

Features

  • Request permissions to modify calendars on the user's device
  • Check if permissions to modify the calendars on the user's device have been granted
  • Add or retrieve calendars on the user's device
  • Retrieve events associated with a calendar
  • Add, update or delete events from a calendar
  • Set up, edit or delete recurring events
    • NOTE: Editing a recurring event will currently edit all instances of it
    • NOTE: Deleting multiple instances in Android takes time to update, you'll see the changes after a few seconds
  • Add, modify or remove attendees and receive if an attendee is an organiser for an event
  • Setup reminders for an event
  • Specify a time zone for event start and end date
    • NOTE: Due to a limitation of iOS API, single time zone property is used for iOS (event.startTimeZone)
    • NOTE: For the time zone list, please refer to the TZ database name column on Wikipedia

Timezone support with TZDateTime

Due to feedback we received, starting from v4.0.0 we will be using the timezone package to better handle all timezone data.

This is already included in this package. However, you need to add this line whenever the package is needed.

import 'package:timezone/timezone.dart';

If you don't need any timezone specific features in your app, you may use flutter_native_timezone to get your devices' current timezone, then convert your previous DateTime with it.

import 'package:flutter_native_timezone/flutter_native_timezone.dart';

// As an example, our default timezone is UTC.
Location _currentLocation = getLocation('Etc/UTC');

Future setCurentLocation() async {
  String timezone = 'Etc/UTC';
  try {
    timezone = await FlutterNativeTimezone.getLocalTimezone();
  } catch (e) {
    print('Could not get the local timezone');
  }
  _currentLocation = getLocation(timezone);
  setLocalLocation(_currentLocation);
}

...

event.start = TZDateTime.from(oldDateTime, _currentLocation);

For other use cases, feedback or future developments on the feature, feel free to open a discussion on GitHub.

Null-safety migration

From v3.9.0, device_calendar is null-safe. However, not all workflows have been checked and bugs from older versions still persist.

You are strongly advised to test your workflow with the new package before shipping. Better yet, please leave a note for what works and what doesn't, or contribute some bug fixes!

Android Integration

The following will need to be added to the AndroidManifest.xml file for your application to indicate permissions to modify calendars are needed

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

Proguard / R8 exceptions

By default, all android apps go through R8 for file shrinking when building a release version. Currently, it interferes with some functions such as retrieveCalendars().

You may add the following setting to the ProGuard rules file proguard-rules.pro (thanks to Britannio Jarrett). Read more about the issue here

-keep class com.builttoroam.devicecalendar.** { *; }

See here for an example setup.

For more information, refer to the guide at Android Developer

AndroidX migration

Since v0.1.0, this version has migrated to use AndroidX instead of the deprecated Android support libraries. When using v0.10.0 and onwards for this plugin, please ensure your application has been migrated following the guide here

iOS Integration

For iOS 10 support, you'll need to modify the Info.plist to add the following key/value pair

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

Note that on iOS, this is a Swift plugin. There is a known issue being tracked here by the Flutter team, where adding a plugin developed in Swift to an Objective-C project causes problems. If you run into such issues, please look at the suggested workarounds there.

Comments
  • Implementing Rrule package

    Implementing Rrule package

    New Pull Request for #400, related to #298

    Currently working in example:

    • [x] can build daily or weekly recurring events.
    • [x] can build monthly or yearly events.
    • [x] can build complex (eg. multi days a week) events.
    • [x] can delete all events in the chain.
    • [x] can delete single events.
    • [x] can delete this and following instances

    Hurdles (all should be solved before merge):

    • [x] rrule changes are published.
    • [x] most features are working / non-working features hidden and labeled.
    • [x] re-enable lower API support (full or partial), or document why they should be dropped.
    enhancement help wanted good first issue hacktoberfest-accepted 
    opened by GoldenSoju 19
  • Allday property resulting in incorrect event

    Allday property resulting in incorrect event

    Reported issue: 'the property "Event.allDay = true;" doesn't save the event correctly in the calendar.'

    Further comments: this appears to be an issue on Android based on the timezone of the event (eg setting an all day event with a start day before 11am AEST results in the event being for the previous day)

    bug 
    opened by nickrandolph 19
  • CI/CD upgrade

    CI/CD upgrade

    Related to #344

    Somehow the latest dependency upgrade is not working here. It seems that the flutter used within the server was and old version.

    We may need to upgrade the current azure pipeline, or maybe switch to github action?

    opened by thomassth 18
  • SWIFT_VERSION attribute set

    SWIFT_VERSION attribute set

    device_calendar does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.

    opened by AdrianJCo 17
  • Forced null safety

    Forced null safety

    After updating dependencies and running dart migrate, and with a few manual patches, this is the kind-of functional null safety enabled device_calendar.

    Tested and working functions (because I use them):

    • [x] retrieveCalendars() retrieves calendar on Android
    • [x] Event event(calendarId_String) can be set correctly (although I still find it confusing to use a number as a string)
    • [x] createOrUpdateEvent() added calendar event to the selected calendar

    If anyone is interested please test it with other functions and see if they run, and better yet, help fixing other bugs.

    To use this instead of the published package:

    1. Save it to somewhere convenient, like next to your app package:

    Parent FolderYourAppdevice_calendar_null

    1. add this to your pubspec.yaml

    dependencies:

    device_calendar:

    path: ../device_calendar/
    
    1. Run flutter pub get
    opened by thomassth 14
  • Event not showing up on the calendar

    Event not showing up on the calendar

    hey I am using the latest version in flutter app, trying to create an event. I see that the code return success, but when I go into the calendar, I see that event is not created. I would really appreciate any pointers as to why I am not seeing events in the calendar.

    in a code I am setting the calendar in a method, and calling another method to create the event.

           calendarsResult = await _deviceCalendarPlugin.retrieveCalendars();
           setState(() {
            _selectedCalendar = calendarsResult?.data[0];
            _addEventsToCalendar(_academicEvents);
           });
    
    Future _addEventsToCalendar(List<AcademicEvent> events) async {
        if (_selectedCalendar != null) {
         if (events != null && events.length > 1) {
           for (var event in events) {
          final eventTime = new DateTime(event.eventStartDate.year, event.eventStartDate.month,   event.eventStartDate.day);
          final eventToCreate = new Event(_selectedCalendar.id);
          eventToCreate.title = event.eventSummary;
          eventToCreate.start = eventTime;
          eventToCreate.description = event.eventSummary;
          ;
          String eventId = event.eventUID.toString();
          if (eventId != null) {
            eventToCreate.eventId = eventId;
          }
          eventToCreate.end = new DateTime(DateFormat.yMMMd().format(eventStartDate));
          final createEventResult =
              await _deviceCalendarPlugin.createOrUpdateEvent(eventToCreate);
          if (createEventResult.isSuccess &&
              (createEventResult.data?.isNotEmpty ?? false)) {
            //print("events added to local calander");
          }
        }
      }
    }
    
    more information required 
    opened by bodamithun 14
  •  Not able to add calendar event to google pixel phones.

    Not able to add calendar event to google pixel phones.

    I am trying to add calendar event to google pixel phone. But i am not able to add it and i couldn't find Default calendar (My Calendar) in calendar app also.
    Is there any thing i need to setup in my app to work with google pixel phones?

    one more issue is like, i am not able to set "Timezone" while creating event.

    question 
    opened by ssivagnanam 14
  • Flutter build api --release issue

    Flutter build api --release issue

    I have been gotten issue with retrieveCalendars when build release.

    If I build project by code, device_calendar work well. But if I build release apk and then install by generated apk. this method cannot retrieveCalendars on device.

    Please help me about this.

    Thanks

    bug 
    opened by thanhhuan1990 14
  • Problems with flutter publish

    Problems with flutter publish

    Part of #346

    Appearantly our publish credentials are expired since March. That's why our action stuck in a loop.

    Also see https://github.com/sakebook/actions-flutter-pub-publisher/issues/22

    I think @nickrandolph need to get a new one from pub.dev

    opened by thomassth 12
  • Feat: v2 embedding

    Feat: v2 embedding

    Why: It seems that the V2 embedding was not applied to the plugin file, Just to the manifest.

    What: This PR adds support for v2 embedding.

    Documentation:

    https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration https://csdcorp.com/blog/coding/handling-permission-requests-in-android-for-flutter-plugins/

    Related issues:

    #326

    help wanted 
    opened by diegog-sf 12
  • result from retrieveCalendars() returns id and name = null on Android

    result from retrieveCalendars() returns id and name = null on Android

    Only on Android (IOS is working fine, same code), I'm getting back a non-empty array with the right amount of calendars (length 2), but the actual fields are all null, (id, name etc..) any ideas? permissions are granted correctly, I tried both on the simulator and on a real device

    final calendarsResult = await _deviceCalendarPlugin.retrieveCalendars();

    Screen Shot 2020-04-03 at 9 45 00 AM

    Screen Shot 2020-04-03 at 10 14 59 AM

    more information required 
    opened by chuckinSpace 12
  • updates/changes are not reflecting on Google Calendar when updating an event using createOrUpdateEvent() method.

    updates/changes are not reflecting on Google Calendar when updating an event using createOrUpdateEvent() method.

    I am running flutter application in Android devices, when i am creating an event in flutter application then it is also visible on Google Calendar with all details that i added in flutter application using createOrUpdateEvent() method. But the problem is that when i updating an already created event's details( title, description, location, start date and end date ) in flutter application then it is not updating in Google Calendar. I am also not receiving any exception or error in debug mode while updating details.

    I am facing this issue in almost android devices. But in some android devices(like Samsung Galaxy M10) when i am updating details(title, start date etc.) then these details are also changing in Google Calendar.

    Working correct in following devices:-

    1. Samsung Galaxy M10
    2. Redmi 11

    Not working in following devices:-

    1. Redmi Note 9
    2. Motorola e5 plus
    3. Samsung galaxy on next

    I am using device_calendar latest version that is ^4.2.0

    Flutter doctor [✓] Flutter (Channel stable, 3.3.9, on macOS 12.6.1 21G217 darwin-x64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 14.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] VS Code (version 1.73.1) [✓] Connected device (3 available) [✓] HTTP Host Availability

    bug 
    opened by sumitrvi 2
  • macOS Supported.

    macOS Supported.

    I have modified from iOS Source Code and make it work in macOS.

    What I have changed:

    • Reuse model attendee from iOS. (dart file)
    • Update Plugin configuration.
    • Modified DeviceCalendarPlugin swift file, I think we can re-use if some one has more exprience in Swift (not by me)
    • Remove UIKit, EventKitUI (only supported in iOS).
    • Remove show event detail in modal by iOS (macOS does not has UIKit).
    • Migrate from UIColor -> NSColor (supported by macOS)

    For the future, I think we can conduct code in Swift and find the extension for support both iOS and macOS.

    Feel free ask me if you want to do anything.


    Notes:

    • Please add this into Info.plist
    	<key>NSCalendarsUsageDescription</key>
    	<string>Access most functions for calendar viewing and editing.</string>
    
    • Also, add this into entitlement file
    	<key>com.apple.security.personal-information.calendars</key>
    	<true/>
    

    In-case you run code for checking, please run by command-line instead of dirrectly from VS code or Android Studio, I think that bug from Flutter.

    flutter run -d macos
    
    opened by kingvhit 2
  • Remove faulty requestPermissions implementation in favor of working one

    Remove faulty requestPermissions implementation in favor of working one

    Tthe current Swift-implentation of requestPermissions does not return if permissions have already been granted. Thus, if it is called more than once, subsequent attempts try to request permissions again, causing the call to fail with a 400-error (To create or update an all day event you must provide calendar ID, event with a title and event's start date).

    There was already a second implementation of requestPermissions which wasn't used anywhere but correctly short-circuits if permissions have already been granted so I thought it would be better to use that.

    EDIT: Actually, the errors seem to be caused by an error on my end. Regardless, this change seems reasonable to me, if less urgent :)

    opened by tjarvstrand 0
  • Not working in the built and release mode

    Not working in the built and release mode

    I have integrated the device calendar plugin in my project and all the functions are working fine when I run the code but when I run it in release mode or make a built to release, these functionalities are not working

    bug 
    opened by ARAVINDKARATE 1
  • Android build fails - Deprecated api

    Android build fails - Deprecated api

    Hi,

    Flutter pub get outputs some warnings about device_calendar :

    The plugin `device_calendar` uses a deprecated version of the Android embedding.
    To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future
    release of Flutter will remove these deprecated APIs.
    If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
    
    

    And app build fails for Android :

    e: [...]snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/device_calendar-3.9.0/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt: (674, 36): Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Activity?
    e: [...]snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/device_calendar-3.9.0/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt: (870, 65): Using 'max(): T?' is an error. Use maxOrNull instead.
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':device_calendar:compileReleaseKotlin'.
    > A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
       > Compilation error. See log for more details
    

    This is my flutter doctor summary :

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.3.9, on Ubuntu 20.04.5 LTS 5.4.0-135-generic, locale fr_FR.UTF-8)
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    [✓] Chrome - develop for the web
    [✓] Linux toolchain - develop for Linux desktop
    [✓] Android Studio (version 2020.3)
    [✓] VS Code (version 1.74.0)
    [✓] Connected device (3 available)
    [✓] HTTP Host Availability
    
    

    Is this package still maintained, is there any solution ?

    Thanks

    opened by Pingolus 1
  • Unable to run the app due to dart:html package

    Unable to run the app due to dart:html package

    I used device_calendar: ^4.2.0 to add event to local mobile device calendar,

    But I can't run the app, when I try to run the app I face the following error.

    /C:/Users/fasik/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/timezone-0.8.0/lib/browser.dart:16:8: Error: Not found: 'dart:html'
    import 'dart:html';
           ^
    
    /C:/Users/fasik/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/timezone-0.8.0/lib/browser.dart:47:10: Error: Undefined name 'HttpRequest'.
      return HttpRequest.request(path,
             ^^^^^^^^^^^
    

    flutter doctor -v

    [✓] Flutter (Channel stable, 2.10.4, on Microsoft Windows [Version 10.0.22000.1219], locale en-US)
        • Flutter version 2.10.4 at C:\src\flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision c860cba910 (9 months ago), 2022-03-25 00:23:12 -0500
        • Engine revision 57d3bac3dd
        • Dart version 2.16.2
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
        • Android SDK at C:\Users\fasik\AppData\Local\Android\sdk
        • Platform android-TiramisuPrivacySandbox, build-tools 33.0.0
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Chrome - develop for the web
        • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
    
    [✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.2)
        • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
        • Visual Studio Community 2022 version 17.4.33122.133
        • Windows 10 SDK version 10.0.22000.0
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at C:\Program Files\Android\Android Studio
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    
    [✓] VS Code (version 1.73.1)
        • VS Code at C:\Users\fasik\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.54.0
    
    [✓] Connected device (3 available)
        • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22000.1219]
        • Chrome (web)      • chrome  • web-javascript • Google Chrome 108.0.5359.71
        • Edge (web)        • edge    • web-javascript • Microsoft Edge 107.0.1418.62
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    

    What can be the issue? how to resolve this?

    bug 
    opened by fasikawsow 4
Releases(4.3.0+3635229635)
Owner
Built to Roam
At Built to Roam we build consumer and line-of-business (LOB) apps that solve real-world problems.
Built to Roam
A social media app where people can post images, follow users ,chat with other users and much more.

Nallagram A Social media app (Both frontend and backend) created with Flutter and Firebase.(inspired from instagram) Show some ❤️ and star ⭐ the repo

Pranav Ajay 34 Jan 6, 2023
A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter

quick_usb A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter Usage List devices List devices with additional description Get device

Woodemi Co., Ltd 39 Oct 1, 2022
A Flutter plugin for retrieving the device locale information.

A Flutter plugin for retrieving the device locale information. Installation Add this to your package's pubspec.yaml file: dependencies: flutter_devi

Florin Bratan 20 Sep 8, 2022
A Flutter Plugin to check Android device Root status and execute shell commands with root privileges

root plugin A Flutter Plugin to check Android device Root status and Run shell commands in android(only). This plugin is based on Topjohnwu libsu and

Gokulprasanth 12 Nov 15, 2022
A simple, cross-platform password manager created with Flutter.

PassMan PassMan Logo © 2021 by Yash Ahir is licensed under CC BY-NC 4.0 A simple, cross-platform password manager created with Flutter. How to run thi

Yash Ahir 19 Dec 14, 2022
This is the new version of my Task app "Tasko" which was done in Java. She is now in Flutter for the HotReload and the native Cross-Platform.

tasko_rem The Tasko App is now compatible on iOS, Android and others distribution, because it's made with Flutter ✨ You can now add task, check them o

Scythe 12 May 2, 2022
Private, cross-platform package tracking app

LibreTrack Private, cross-platform package tracking app. Track postal items directly on your device using accounts of postal services. The app respect

Yaroslav Pronin 128 Jan 1, 2023
Cross-platform Twitch Chat application with 3rd-party addon support!

Chatsen Chatsen is a cross-platform application that allows you to chat on Twitch with support for 3rd-party services such as 7TV, BTTV and FFZ. It al

Chatsen 172 Dec 31, 2022
A cross platform GUI, soon to be the official GUI.

CCExtractor Flutter GUI The new cross platform interface is all you need, as it includes all the options. After installing GUI you will have a shortcu

CCExtractor Development 16 Nov 19, 2022
Sharik is an open-source, cross-platform solution for sharing files via Wi-Fi or Mobile Hotspot

Share files across devices with Sharik! It works with Wi-Fi connection or Tethering (Wi-Fi Hotspot). No internet connection needed. Contributing Feel

Mark Motliuk 844 Jan 1, 2023
Drishti is an open-source cross-platform mobile application project at Incubate Nepal that incorporates Machine Learning and Artificial Intelligence

Drishti is an open-source cross-platform mobile application project at Incubate Nepal that incorporates Machine Learning and Artificial Intelligence to help visually impaired people recognize different currency bills and perform daily cash transactions more effectively. We plan to expand Drishti to other applications like Short Text and Document Reading in the future.

Drishti Nepal 23 Oct 8, 2022
Music reader for online data (Google Drive implementation). Cross platform goal : iOS, Android, MacOS, Windows

omusic A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

JeanNicolasdeLamballerie 0 Nov 30, 2021
Cross platform application for iOS and Android using Google's SDK Flutter.

scout Cross platform application for iOS and Android using Google's SDK Flutter. Launch screen for the application. The menu for selecting cookies. Cu

null 0 Nov 9, 2021
The next-generation cross-platform Minecraft Launcher.

MultiFold MultiFold is the next-generation cross-platform Minecraft launcher. This project is currently work-in-progress. Contributing You are welcome

MultiFold 29 Nov 9, 2022
A beautiful, cross-platform, encrypted password manager 🔐

Passwd. A beautiful, encrypted password manager, built using Flutter and Dart. Note: This project is unmaintained for now Features Fully encrypted usi

Passwd. 145 Dec 22, 2022
The Fuse Wallet is a cross platform Ethereum wallet written in Dart and built on Flutter.

Fuse Wallet The Fuse Wallet is a cross platform Ethereum wallet written in Dart and built on Flutter. It's runninng on the Fuse network, but can be pl

null 4 Nov 9, 2022
Super Fast Cross Platform Database for Flutter & Web Apps

Isar Database ?? Alpha version - Use with care. ?? Quickstart • Documentation • Sample Apps • Support & Ideas • Pub.dev Isar [ee-zahr]: River in Bavar

Isar Database 2.1k Jan 1, 2023
A cross platform application written in flutter to help people stick to their routines and achieve their goals

Scheduler Scheduler is a cross platform application written in flutter to help people stick to their routines and achieve their goals. Our service inc

Sidheshwar S 3 Jan 21, 2022