Flutter local notifications work in debug but not in release APK (app closes / notifications not triggering)

17 hours ago 1
ARTICLE AD BOX

Description

I’m building a Flutter productivity app that helps users stay focused by tracking sessions and scheduling task reminders using local notifications.

App Overview

Users can create tasks with a specific reminder time

Each task schedules a local notification

Users can start focus sessions (timer-based)

The app tracks stats like:

total focus time

daily progress

streaks

On app startup, all saved tasks are reloaded and notifications are rescheduled


Problem

Everything works correctly in debug mode, but in the release APK:

❌ Notifications do not trigger

❌ App sometimes closes automatically on startup

❌ Previously scheduled tasks are not firing notifications


What I’m doing

Initialization (main.dart)

void main() async { WidgetsFlutterBinding.ensureInitialized(); try { await NotificationService.init(); final taskService = TaskService(); await taskService.rescheduleAllTasks(); } catch (e) { // prevent crash } if (Platform.isAndroid) { final androidInfo = await DeviceInfoPlugin().androidInfo; if (androidInfo.version.sdkInt >= 33) { await Permission.notification.request(); } } runApp(const FlamziApp()); }

Notification Scheduling

await notificationsPlugin.zonedSchedule( id, title, body, scheduledDate, notificationDetails, androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle, uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime, );

What I’ve already checked

Notifications permission is granted

Using valid future times (not past)

Works perfectly in debug mode

No visible errors in debug logs

Using timezone-based scheduling (zonedSchedule)

Using inexactAllowWhileIdle mode


Expected Behavior

Notifications should trigger at scheduled time

App should not crash on startup

Tasks should reschedule correctly on app launch


Actual Behavior (Release APK)

Notifications never appear

App sometimes closes immediately on launch

Scheduling seems to fail silently

Read Entire Article