app_blocker 1.0.5 copy "app_blocker: ^1.0.5" to clipboard
app_blocker: ^1.0.5 copied to clipboard

Cross-platform app blocking plugin for Flutter. Block apps with overlay (Android) and Screen Time Shield (iOS). Supports scheduling, focus profiles, and real-time blocking events.

app_blocker #

pub package license

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 granted
  • requestPermission() — Request permissions from user
  • getApps() — Get list of installed apps (Android) or show app picker (iOS)
  • blockApps(List<String>) — Block specific apps
  • blockAll() — Block all apps
  • unblockApps(List<String>) — Unblock specific apps
  • unblockAll() — Unblock all apps
  • getBlockedApps() — Get list of currently blocked apps
  • getAppStatus(String) — Check block status of a specific app
  • setOverlayConfig(OverlayConfig) — Customize block overlay (Android only)
  • addSchedule(BlockSchedule) — Add a blocking schedule
  • onBlockEvent — Stream of block/unblock events
  • getCapabilities() — 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.0

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

  1. Open ios/Runner.xcworkspace in Xcode
  2. Runner target > Signing & Capabilities > add Family Controls
  3. 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.

7
likes
0
points
363
downloads

Publisher

unverified uploader

Weekly Downloads

Cross-platform app blocking plugin for Flutter. Block apps with overlay (Android) and Screen Time Shield (iOS). Supports scheduling, focus profiles, and real-time blocking events.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on app_blocker

Packages that implement app_blocker