搜索插件、代码仓与 APP 分类

插件详情v3.1.1

add_2_calendar

一个非常简单的 Flutter 插件,用于将事件添加到每个平台的默认日历中。

AndroidiOS
近 30 天下载
15.9万
喜欢数
364
Pub 分数
160

安装插件

flutter pub add add_2_calendar

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个轻量级的Flutter插件,可在Android和iOS的默认日历中添加日历事件。它提供了一个简单的API,可轻松创建和安排事件,设置简单,非常适合需要日历集成的应用程序。该插件会自动处理平台特定的差异,确保在各种设备上行为一致。它支持基本的事件详情,如标题、日期、时间和描述。

适合场景

  • 安排预约
  • 向日历添加提醒
  • 在生产力应用中集成事件创建
  • 在应用内部启用事件共享
  • 支持会议邀请

主要特点

  • 跨平台兼容性
  • 简单事件创建 API
  • 自动平台处理
  • 支持事件标题、日期、时间和描述
  • 所需配置最少

适合对象

  • 开发集成日历的应用程序的开发者
  • 需要快速添加事件的应用程序
  • 针对 Android 和 iOS 的项目
  • 希望获得简单日历访问权限的团队

使用建议

  • 需要用户权限才能访问日历
  • 仅限基本事件属性
  • 不支持重复事件
  • 取决于设备的默认日历应用
  • 可能需要在 Android 上授予额外权限

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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!

所属分类

源码仓库

使用此插件的项目