79662787

Date: 2025-06-12 00:10:04
Score: 1
Natty:
Report link

Alright, so this is one of those classic Flutter notification quirks that loves to waste your time. You’ve got the zonedSchedule call working just enough to add a pending notification, but then it just chills in limbo like it's waiting for a divine signal that never comes. First off, make sure you’ve actually initialized your timezone — and no, not just initializeTimeZones(), but also setLocalLocation() using flutter_timezone. Without that, tz.local is basically a confused tourist with no map. Put it in main() before anything else runs.

Then we get to Android 12+, where Google decided that exact alarms are dangerous and must be tamed. So yes, even if you slapped <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/> into the manifest, it still does nothing unless the user manually gives your app permission through system settings. You can try triggering Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM) on the native side, but for debugging, just test on Android 11 or below first so you don’t lose your mind.

Also, your scheduling logic seems fine on paper, but remember: if the scheduled time is even a hair too close to DateTime.now(), it might just silently ignore it. Add a buffer, like 30 seconds, just to be safe. That means tz.TZDateTime.from(DateTime.now().add(Duration(seconds: 30)), tz.local), not some half-second offset that gets eaten by execution delay. Oh, and androidAllowWhileIdle: true should always be set if you want it to actually fire when the device is dozing off in a dark corner.

So in summary:

– Initialise the timezone properly, not halfway.

– Android 12+ needs manual permission for exact alarms.

– Always give it a scheduling buffer.

– androidAllowWhileIdle must be set.

– If it works with show() but not zonedSchedule(), then congrats: the problem is timezone, permissions, or scheduling time — pick your poison.

Hope this spares you the descent into madness. Let me know if you want a full working example that’s not possessed.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user30781136