{"id":16746587,"url":"https://github.com/helightdev/persistent_device_calendar","last_synced_at":"2025-03-16T02:16:40.015Z","repository":{"id":61975585,"uuid":"544499166","full_name":"helightdev/persistent_device_calendar","owner":"helightdev","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-02T16:29:43.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T15:09:50.573Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helightdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-02T16:28:28.000Z","updated_at":"2022-10-02T16:28:48.000Z","dependencies_parsed_at":"2022-10-24T13:45:27.667Z","dependency_job_id":null,"html_url":"https://github.com/helightdev/persistent_device_calendar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helightdev%2Fpersistent_device_calendar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helightdev%2Fpersistent_device_calendar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helightdev%2Fpersistent_device_calendar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helightdev%2Fpersistent_device_calendar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helightdev","download_url":"https://codeload.github.com/helightdev/persistent_device_calendar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814895,"owners_count":20352038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T02:07:19.694Z","updated_at":"2025-03-16T02:16:39.994Z","avatar_url":"https://github.com/helightdev.png","language":"Dart","readme":"# Persistent Device Calendar\n## Features\nThis package contains a wrapper for the device_calendar plugin which adds persistence and \nquality-of-life improvements, reducing boilerplate code in common use-cases, as well as\nimproving code readability and simplicity.\n\nNOTE: This package currently only aims to provide basic calendar functionality, recurrence\nfor events has not been tested with this package and is considered not supported.\n\n## Example\n```dart\nvoid usage() async {\n  var calPlugin = PersistentDeviceCalendar();\n  if (!await calPlugin.setup()) return; // Setup permissions or return if not granted\n  \n  var start = TZDateTime.now(getLocation(\"America/Detroit\")); // Constant debug times\n  var end = start.add(const Duration(hours: 2));\n  \n  var calendar = await calPlugin.getCalendar\u003cCustomEvent\u003e(name: \"Custom Events\",\n      builder: (event, calendarId, eventId) =\u003e Event(calendarId, eventId: eventId, title: event.name, start: start, end: end),\n      idSelector: (event) =\u003e event.id\n  );\n  await calendar.prune(); // Optionally remove registered events which have been deleted on the device\n\n  var events = [\n    CustomEvent(id: \"a\", name: \"Event A\"),\n    CustomEvent(id: \"b\", name: \"Event B\"), \n    CustomEvent(id: \"c\", name: \"Event C\")\n  ];\n  await calendar.put(events); // Put events, possibly replacing old version\n}\n\nclass CustomEvent {\n\n  String id;\n  String name;\n\n  CustomEvent({\n    required this.id,\n    required this.name,\n  });\n}\n```\n\n## Timezones with TZDateTime (from device_calendar)\nDue to feedback we received, starting from `4.0.0` we will be using the `timezone` package to\nbetter handle all timezone data.\n\nThis is already included in this package. However, you need to add this line\nwhenever the package is needed.\n\n```dart\nimport 'package:timezone/timezone.dart';\n```\n\nIf you don't need any timezone specific features in your app, you may use `flutter_native_timezone`\nto get your devices' current timezone, then convert your previous `DateTime` with it.\n\n```dart\nimport 'package:flutter_native_timezone/flutter_native_timezone.dart';\n\n// As an example, our default timezone is UTC.\nLocation _currentLocation = getLocation('Etc/UTC');\n\nFuture setCurentLocation() async {\n  String timezone = 'Etc/UTC';\n  try {\n    timezone = await FlutterNativeTimezone.getLocalTimezone();\n  } catch (e) {\n    print('Could not get the local timezone');\n  }\n  _currentLocation = getLocation(timezone);\n  setLocalLocation(_currentLocation);\n}\n\n...\n\nevent.start = TZDateTime.from(oldDateTime, _currentLocation);\n```\n\nFor other use cases, feedback or future developments on the feature, feel free to\nopen a discussion on GitHub.\n\n## Platform Setup (from device_calendar)\n### Android Integration\n\nThe following will need to be added to the `AndroidManifest.xml` file for your application to\nindicate permissions to modify calendars are needed\n\n```xml\n\u003cuses-permission android:name=\"android.permission.READ_CALENDAR\" /\u003e\n\u003cuses-permission android:name=\"android.permission.WRITE_CALENDAR\" /\u003e\n```\n\n#### Proguard / R8 exceptions\n\nBy default, all android apps go through R8 for file shrinking when building a release version.\nCurrently, it interferes with some functions such as `retrieveCalendars()`.\n\nYou may add the following setting to the ProGuard rules file `proguard-rules.pro`\n(thanks to [Britannio Jarrett](https://github.com/britannio)). Read more about the issue\n[here](https://github.com/builttoroam/device_calendar/issues/99)\n\n```\n-keep class com.builttoroam.devicecalendar.** { *; }\n```\n\nSee [here](https://github.com/builttoroam/device_calendar/issues/99#issuecomment-612449677)\nfor an example setup.\n\nFor more information, refer to the guide at\n[Android Developer](https://developer.android.com/studio/build/shrink-code#keep-code)\n\n#### AndroidX migration\n\nSince `v.1.0`, this version has migrated to use AndroidX instead of the deprecated\nAndroid support libraries. When using `0.10.0` and onwards for this plugin, please ensure your\napplication has been migrated following the guide\n[here](https://developer.android.com/jetpack/androidx/migrate)\n\n### iOS Integration\n\nFor iOS 10+ support, you'll need to modify the `Info.plist` to add the following key/value pair\n\n```xml\n\u003ckey\u003eNSCalendarsUsageDescription\u003c/key\u003e\n\u003cstring\u003eAccess most functions for calendar viewing and editing.\u003c/string\u003e\n\n\u003ckey\u003eNSContactsUsageDescription\u003c/key\u003e\n\u003cstring\u003eAccess contacts for event attendee editing.\u003c/string\u003e\n```\n\nNote that on iOS, this is a Swift plugin. There is a known issue being tracked\n[here](https://github.com/flutter/flutter/issues/16049) by the Flutter team, where adding a plugin\ndeveloped in Swift to an Objective-C project causes problems. If you run into such issues, please\nlook at the suggested workarounds there.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelightdev%2Fpersistent_device_calendar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelightdev%2Fpersistent_device_calendar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelightdev%2Fpersistent_device_calendar/lists"}