app_blocker
A Flutter plugin to block apps on Android and iOS.
- Android: Foreground service + overlay window to detect and block apps
- iOS: Screen Time API
- FamilyControls — request user authorization to manage Screen Time
- ManagedSettings — apply shield restrictions on selected apps (required for blocking specific apps, not needed for
blockAll())
Supported Functions
checkPermission()— Check if required permissions are grantedrequestPermission()— Request permissions from usergetApps()— Get list of installed apps (Android) or show app picker (iOS)blockApps(List<String>)— Block specific appsblockAll()— Block all appsunblockApps(List<String>)— Unblock specific appsunblockAll()— Unblock all appsgetBlockedApps()— Get list of currently blocked appsgetAppStatus(String)— Check block status of a specific appsetOverlayConfig(OverlayConfig)— Customize block overlay (Android only)addSchedule(BlockSchedule)— Add a blocking scheduleonBlockEvent— Stream of block/unblock eventsgetCapabilities()— Check available features on current platform
Platform Support
| Feature | Android | iOS |
|---|---|---|
| Block / Unblock apps | ✅ | ✅ |
| Block all apps | ✅ | ✅ |
| Get installed apps | ✅ | - |
| Custom overlay | ✅ | - |
| Screen Time Shield | - | ✅ |
| Schedules | ✅ | ✅ |
| Block events stream | ✅ | ✅ |
| Boot persistence | ✅ | - |
Installation
dependencies:
app_blocker: ^1.0.6
Setup
Android
Minimum SDK: 24 (Android 7.0)
Add to android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
</manifest>
iOS
Minimum iOS: 16.0
- Open
ios/Runner.xcworkspacein Xcode - Runner target > Signing & Capabilities > add Family Controls
- Set deployment target in
ios/Podfile:
platform :ios, '16.0'
Usage
import 'package:app_blocker/app_blocker.dart';
final blocker = AppBlocker.instance;
Permission
// Check permission status
final status = await blocker.checkPermission();
// Returns: BlockerPermissionStatus.granted / .denied / .restricted
// Request permission (opens system settings on Android, shows dialog on iOS)
await blocker.requestPermission();
Get Apps & Block
Android:
// Get all installed apps (returns list with appName, packageName, icon)
final apps = await blocker.getApps();
// Block using package names
await blocker.blockApps(apps.map((a) => a.packageName).toList());
iOS:
// Opens FamilyActivityPicker — user selects apps → automatically blocked
await blocker.getApps();
Common:
await blocker.blockAll();
await blocker.unblockAll();
final blocked = await blocker.getBlockedApps();
Overlay Config (Android only)
await blocker.setOverlayConfig(
const OverlayConfig(
title: 'Stay Focused!',
subtitle: 'This app is blocked',
message: 'Get back to work.',
backgroundColor: Color(0xDD000000),
),
);
// iOS uses system Screen Time Shield automatically
Schedules
// Add a schedule
await blocker.addSchedule(BlockSchedule(
id: 'work-hours',
name: 'Work Hours',
appIdentifiers: ['com.instagram.android'],
weekdays: [1, 2, 3, 4, 5], // Mon-Fri (ISO 8601)
startTime: const TimeOfDay(hour: 9, minute: 0),
endTime: const TimeOfDay(hour: 17, minute: 0),
));
await blocker.enableSchedule('work-hours');
await blocker.disableSchedule('work-hours');
await blocker.removeSchedule('work-hours');
final schedules = await blocker.getSchedules();
Block Events
blocker.onBlockEvent.listen((event) {
print('${event.type}: ${event.packageName}');
});
// Event types: blocked, unblocked, attemptedAccess,
// scheduleActivated, scheduleDeactivated
Capabilities
// Check what features are available on current platform
final caps = await blocker.getCapabilities();
Example
See the example app for a complete working demo.
License
MIT — see LICENSE.
Libraries
- app_blocker
- Cross-platform app blocking plugin for Flutter.