Calendar Permission Handler
Component Detail
Description
Handles the OS-level calendar permission lifecycle on both iOS and Android, presenting a contextual in-app rationale screen before triggering the platform's native permission dialog. Follows platform guidelines for permission request timing - the rationale is shown only once before the first OS prompt, and the handler gracefully manages the denied/permanently-denied states without crashing the sync flow.
calendar-permission-handler
Sources & reasoning
Calendar access is a sensitive OS-level permission on both iOS and Android requiring a runtime grant. Platform guidelines mandate a contextual rationale before the system dialog to avoid one-shot rejections. This infrastructure component encapsulates the full permission lifecycle so CalendarSyncService never needs to know about platform-specific permission APIs.
No source references — this artifact was included based on reasoning alone (see above).
Responsibilities
- Display an in-app rationale screen explaining why calendar access is needed before the OS dialog appears
- Trigger the iOS and Android runtime permission request via the device_calendar plugin
- Handle all permission states: granted, denied, permanently denied (Settings redirect)
- Persist permission state locally to avoid re-prompting on every app launch
- Expose a single permission gate used by CalendarSyncService before any write operation
Interfaces
requestCalendarPermission(): Future<CalendarPermissionStatus>
hasCalendarPermission(): Future<bool>
showPermissionRationale(context: BuildContext): Future<bool>
openAppSettings(): Future<void>