/flutter:local-notifications-schedulerfrom Flutter Skills
Enforces an on-device reminder engine with a local DB as source of truth and OS pending set as disposable cache. Use when scheduling, canceling, or debugging local notifications in Flutter.
Ships in Flutter Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
One on-device reminder engine, owned centrally, with a narrow API. The local DB is the source of truth; the OS pending set is a disposable cache. Every scheduling change flows through one pure-then-reconcile path so the whole engine is verifiable off-device. Applies whenever you schedule, cancel, or reason about local notifications.
Read the reference for the task at hand:
references/notification-gateway-port.md — the port contract, the two adapters, channels/grouping/deep-link payload rules.references/scheduler-and-recurrence-rules.md — pure ReminderScheduler.compute diff, recurrence/DST math, deterministic IDs, budgeting, the full test matrix.references/platform-boot-exact-alarms-oem.md — boot re-arm, exact-alarm degradation, background-isolate safety, Android manifest/Gradle, the OEM survival matrix.Run scripts/check-single-fln-import.sh, scripts/check-scheduler-purity.sh, scripts/check-adhoc-schedule-calls.sh, and scripts/check-manifest-permissions.sh before a PR.
syncNotifications() reconcile entrypoint. Never call gateway.schedule()/cancel() ad hoc from feature or UI code — that path cannot be made idempotent and desyncs the cache.flutter_local_notifications in exactly one file — the FLN adapter. Everything else, including all tests, talks to the NotificationGateway port. A grep gate fails the build on any other import.DateTime.now() inside them — inject a Clock from package:clock: Riverpod code reads it from clockProvider, the pure math takes it as a parameter (never DateTime.now(), never a bespoke ClockService). Purity is what makes off-device unit testing via FakeNotificationGateway possible.TZDateTime only at schedule time. Never persist a recurring schedule as a UTC instant — it drifts an hour across every DST boundary. True one-off instants stay UTC epoch millis.tz.local at startup (from flutter_timezone). The timezone package defaults to UTC — forget this and every zonedSchedule fires at the wrong local hour.AndroidScheduleMode.inexactAllowWhileIdle (permission-free, pierces Doze). Gate exact firing behind the user-revocable SCHEDULE_EXACT_ALARM via canScheduleExactAlarms() with silent fallback to inexact. Never declare USE_EXACT_ALARM — Play policy restricts it to alarm/timer/calendar apps and risks store rejection.reminderId + occurrenceIndex plus a hash of the resolved fire instant and notification content. getPending() exposes only the id, not when — so if the id ignored the fire time, editing a reminder without changing its occurrence (a one-off moved 09:00→14:00, or a daily rule's hour changed) would keep the same id, be skipped by BOTH the cancel and schedule loops, and fire at the OLD time. Folding the resolved TZDateTime (and content) into the id makes an edit produce a NEW id — old id cancelled, new id scheduled. Unchanged input still maps to the same id, so reconcile stays a no-op.The engine is shared infrastructure, not a feature — the pure math lives in core/ (no Flutter, off-device testable) and the side-effect port + live impl + reconcile live in services/. project-structure-and-packages owns this tree.
lib/
core/
notifications/ # PURE — no Flutter, off-device testable
reminder_scheduler.dart # compute(desired) -> reconcile diff
recurrence_rule.dart # wall-clock + rule -> TZDateTime
scheduled_notification.dart # value objects (ScheduledNotification, PendingNotification)
deterministic_id.dart # reminderId + occurrence + resolved instant/content -> id
services/
notifications/ # the side-effect port, live adapter, and reconcile
notification_gateway.dart # abstract PORT: schedule/cancel/cancelAll/getPending
fln_notification_gateway.dart # ONLY file importing flutter_local_notifications
fake_notification_gateway.dart # in-memory list, for tests
sync_notifications.dart # the single reconcile entrypoint
boot_rearm_android.dart # BOOT_COMPLETED post-unlock re-arm
When multi-package (workspace): promote the pure math + gateway into a
packages/notificationspackage (wherelib/src/+ one public barrel is the sanctioned convention) so the ~N features that feed it cannot diverge. In a single-package app thecore/+services/split is enough. Seeproject-structure-and-packages.
Wire construction through Riverpod providers — never global singletons or per-feature instances. The Clock comes from clockProvider (Clock.fixed(...) in tests); see service-boundary-and-native for the throws-until-overridden port provider pattern.
compute is pure; the gateway diff is the only IO. This is the ONE entrypoint every scheduling change flows through.
Future<void> syncNotifications(
NotificationGateway gw,
Clock clock,
ReminderRepository repo,
) async {
final desired = ReminderScheduler.compute( // PURE — no IO, injected clock
reminders: await repo.activeReminders(), // from the local DB (source of truth)
now: clock.now(),
budget: 50, // headroom under the silent iOS 64-cap
); // sorts future instants ascending,
// takes the nearest ~50 as a rolling window
final current = await gw.getPending();
final desiredIds = {for (final d in desired) d.id};
final currentIds = {for (final c in current) c.id};
for (final c in current) { // cancel stale
if (!desiredIds.contains(c.id)) await gw.cancel(c.id);
}
for (final d in desired) { // schedule new / changed
if (!currentIds.contains(d.id)) await gw.schedule(d);
}
}
Call syncNotifications() on: app foreground/resume, reminder CRUD, backup import/restore, exact-alarm permission granted, Android boot, and the daily background tick. See examples/sync_notifications.dart for the annotated version including the after-restore path.
The port isolates the plugin so all scheduling math and all tests stay off-device.
abstract class NotificationGateway {
Future<void> schedule(ScheduledNotification n);
Future<void> cancel(int id);
Future<void> cancelAll();
Future<List<PendingNotification>> getPending();
}
Keep it to exactly these four operations — anything more is a signal the logic belongs in the pure ReminderScheduler. The concrete FlnNotificationGateway is the single file importing flutter_local_notifications, timezone, and flutter_timezone; the FakeNotificationGateway is an in-memory List. Wire the concrete one through a Riverpod provider that tests override with the fake in a ProviderContainer. Full contract and the ScheduledNotification value object: references/notification-gateway-port.md and examples/notification_gateway.dart.
Resolve wall-clock + rule to a TZDateTime in tz.local at schedule time — DST-correct by construction.
// Wall-clock 9:00 daily -> concrete next fire instant, DST-safe.
tz.TZDateTime nextDailyAt(int hour, int minute, {required Clock clock}) {
final now = tz.TZDateTime.from(clock.now(), tz.local);
var next = tz.TZDateTime(tz.local, now.year, now.month, now.day, hour, minute);
if (!next.isAfter(now)) next = next.add(const Duration(days: 1));
return next;
}
Genuinely calendar-recurring items may use one repeating notification (matchDateTimeComponents) consuming a single slot; everything else is a one-shot recomputed each reconcile. Mark-done re-anchoring: compute the next occurrence from the actual completion time, not the scheduled one, so recurring reminders don't drift. Never store "9am" as a UTC instant.
Some apps derive a reminder time from a non-time trigger (e.g. "remind after N completions"). Keep that projection in a pure, Clock-injected helper that resolves to a concrete future instant before it reaches the scheduler, so the scheduler still handles one homogeneous list of instants. Debounce re-projection so a stream of inputs doesn't cause a reschedule storm.
The background tap/action handler needs @pragma('vm:entry-point') and runs in a separate isolate with no main-isolate state. Do not write to the DB from it — record a lightweight "pending action" intent (or nothing) and let the next foreground reconcile do the real work, avoiding concurrent DB access from two isolates. A tap maps a serializable payload → a go_router location reconstructed from the DB — never a non-serializable extra. See async-safety for mounted/context guards after the await, and references/platform-boot-exact-alarms-oem.md.
Notification titles/bodies are localized through gen-l10n with ICU plurals and numeral normalization; the schedule instant stays a Gregorian TZDateTime regardless of display calendar (see i18n-rtl-l10n). Backup does not carry OS notification state or exact-alarm grants — after import, run cancelAll() then a full reconcile; never assume restored pending IDs are valid.
gateway.schedule() from a feature/ViewModel. Desyncs the cache and can't be made idempotent. Route through syncNotifications().DateTime.now() inside the scheduler. Kills off-device testability. Inject a Clock.USE_EXACT_ALARM to "just make it fire on time." Play-policy rejection risk. Use the SCHEDULE_EXACT_ALARM opt-in with inexact fallback.flutter_local_notifications imported in exactly one file (check-single-fln-import.sh passes).check-scheduler-purity.sh passes).gateway.schedule/cancel outside the reconcile (check-adhoc-schedule-calls.sh passes).tz.local set at startup before any zonedSchedule.AndroidScheduleMode chosen from canScheduleExactAlarms(); USE_EXACT_ALARM absent (check-manifest-permissions.sh passes).@pragma('vm:entry-point'), no DB write in the isolate, serializable payload → route.cancelAll() then full reconcile.service-boundary-and-native — the injectable throws-until-overridden port provider and MethodChannel quarantine that the gateway follows.naming-conventions — the [Concern]Gateway suffix (a thin wrapper over a specific plugin, here flutter_local_notifications) vs [Concern]Service; owns the role-suffix table this skill follows.persistence-drift — the local DB that is the source of truth; scoped .watch streams that trigger reconciles.async-safety — BuildContext/mounted guards after await in tap handlers, subscription disposal.state-management-riverpod — providers-as-DI for the gateway and reconcile.i18n-rtl-l10n — localized bodies, ICU plurals, numeral normalization.value-objects-money-and-units — the injected Clock discipline shared here.app-startup-and-bootstrap — where tz.local and channel creation run before runApp.testing-strategy — fakes-over-mocks and clock-injected pure-core testing this engine relies on.examples/fake_notification_gateway.dart (opens in a new tab)examples/notification_gateway.dart (opens in a new tab)examples/sync_notifications.dart (opens in a new tab)references/notification-gateway-port.md (opens in a new tab)references/platform-boot-exact-alarms-oem.md (opens in a new tab)references/scheduler-and-recurrence-rules.md (opens in a new tab)scripts/check-adhoc-schedule-calls.sh (opens in a new tab)scripts/check-manifest-permissions.sh (opens in a new tab)scripts/check-scheduler-purity.sh (opens in a new tab)scripts/check-single-fln-import.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
40 skills in this plugin
/accessibility-as-codeEnforces accessibility as a correctness property authored into each widget — Semantics(button/label) or ExcludeSemantics on every node, a11y state read from MediaQuery not app state, never MediaQuery.withClampedTextScaling / textScaleFactor / FittedBox / TextOverflow.ellipsis to fit a label, non-color redundant channels (icon+label+shape+text) for every state, contrast against composited backgrounds (4.5:1 body / 3:1 large), 44px single-tap targets, OrdinalSortKey traversal, and honoring boldText / reduce-motion. Use when adding a GestureDetector/InkWell or any tap target, adding an Icon or Image, reaching for withClampedTextScaling/FittedBox/ellipsis/textScaleFactor to make text fit, encoding state via color, sizing type, ordering focus traversal, or reviewing any View for screen-reader/switch/low-vision support./adaptive-layoutEnforces adapting layout by available CONSTRAINTS/size, never device or platform checks — LayoutBuilder + MediaQuery.sizeOf/paddingOf/viewInsetsOf (not .of) for narrow rebuilds, Material 3 window size classes (compact <600, medium 600-840, expanded 840-1200, large >1200) as the breakpoint vocabulary, navigation affordance chosen by width (NavigationBar → NavigationRail → NavigationDrawer), list-detail single-pane-vs-two-pane, readable max-width via ConstrainedBox, Flexible/Expanded/FractionallySizedBox over fixed widths, SafeArea + display cutouts + keyboard insets, never lock orientation, foldable/hinge awareness via MediaQuery.displayFeatures, and golden-matrix verification across sizes. Use when building responsive or adaptive UI, tablet/desktop/foldable support, master-detail or two-pane screens, a NavigationRail-vs-BottomNav shell, breakpoints, LayoutBuilder, MediaQuery sizing, SafeArea/cutouts, or fixing overflow at large widths.npx claudepluginhub zakariaf/flutter-skills --plugin flutterOther plugins' skills for the same job