r/FlutterDev • u/kiwi3920 • 17m ago
Article Shipping a Flutter app that blocks other apps on iOS and Android: what bit me
I've been building an app blocker (DetoxScreen) in Flutter since this summer. Flutter does the UI, but the blocking itself has nothing in common between the two platforms, so it's two native engines behind one MethodChannel.
iOS: Screen Time API (FamilyControls / ManagedSettings / DeviceActivity). Most of the logic lives in app extensions where Flutter doesn't run at all.
Android: there's no equivalent. It's UsageStatsManager to know what's in the foreground, a foreground service, and an overlay drawn on top of the blocked app (SYSTEM_ALERT_WINDOW). Two permissions the user has to grant by hand in settings, and the onboarding has to notice when they come back.
Stuff that bit me:
- local_auth on Android needs FlutterFragmentActivity. With plain FlutterActivity, authenticate() throws no_fragment_activity. My wrapper caught every exception and returned false "for safety", so on Android anyone with "protect blocks" on could never remove a block. Found it weeks into the closed test. If you wrap local_auth like that, check your MainActivity.
- Store screenshots: I generate them with integration_test on both platforms. On the Android 14 emulator, demo mode shows the wifi icon twice, had to hide wifi and only show mobile.
- New Google Play accounts need 12 testers for 14 days in a closed test before you can even ask for production. Plan for it, finding the testers took me weeks.
Happy to share code for any of this.