如何通过Flutter在本地日历中创建事件? [英] How can I create events in local calendar by Flutter?

查看:236
本文介绍了如何通过Flutter在本地日历中创建事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试提出申请.我想将事件添加到本地日历.但是我不知道该怎么做.如果有一些简单的例子会更好.

I'm trying to make an application. I want to add events to local calendar. But I don't know how to do that. It would be better if there were some simple examples.

推荐答案

您可以使用插件 add_2_calendar .

在Flutter项目中的pubspec.yaml文件中:

In your pubspec.yaml file within your Flutter Project:

dependencies:
  add_2_calendar: ^1.3.0

iOS集成:

为了使此插件在iOS 10+上运行,请确保将其添加到您的info.plist文件中:

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

用法:

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 */),
    );
...
Add2Calendar.addEvent2Cal(event);
...


另请参阅Flutter文档,以使用软件包.需要使用设备API时,可以在 pub.dev 上查找软件包.


See also Flutter documentation for using packages. You can look for packages on pub.dev when you need to use device APIs.

这篇关于如何通过Flutter在本地日历中创建事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆