flutter_boot_receiver 1.2.0 copy "flutter_boot_receiver: ^1.2.0" to clipboard
flutter_boot_receiver: ^1.2.0 copied to clipboard

PlatformAndroid

A Flutter plugin for registering Dart callbacks when the Android device boots up

flutter_boot_receiver #

A Flutter plugin for registering Dart callbacks when the Android device boots up.

Contents #

Platform Support #

Platform Supported
Android ✔️ Yes
iOS ❌ No
Web ❌ No
Windows ❌ No
Linux ❌ No
MacOS ❌ No

Installation #

  1. flutter pub add flutter_boot_receiver

In your AndroidManifest.xml:

  1. Add android:installLocation="internalOnly" in your manifest tag. Only devices installed in internal storage can receive the BOOT_COMPLETE broadcast in Android.
<manifest
    android:installLocation="internalOnly"
    >
  1. Add the following permission:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
  1. Add the following service and receiver inside your application tag:
<service
    android:name="com.flux.flutter_boot_receiver.BootHandlerService"
    android:exported="false"
    android:permission="android.permission.BIND_JOB_SERVICE"
    />
<receiver
    android:enabled="true"
    android:exported="true"
    android:name="com.flux.flutter_boot_receiver.BootBroadcastReceiver"
    android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</receiver>

Your AndroidManifest.xml should now have a structure similar to this:

<manifest
    android:installLocation="internalOnly"
    >
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <!-- Other permissions... -->
    <application>
        <!-- Other activities, services etc... -->
        <service
            android:name="com.flux.flutter_boot_receiver.BootHandlerService"
            android:exported="false"
            android:permission="android.permission.BIND_JOB_SERVICE"
            />
        <receiver
            android:enabled="true"
            android:exported="true"
            android:name="com.flux.flutter_boot_receiver.BootBroadcastReceiver"
            android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>
    </application>
</manifest>

Usage #

import 'package:flutter_boot_receiver/flutter_boot_receiver.dart';

@pragma('vm:entry-point')
void callback() async {
  // Code here will be executed when the device boots up
}

await BootReceiver.initialize(callback);
5
likes
150
pub points
74%
popularity

Publisher

unverified uploader

A Flutter plugin for registering Dart callbacks when the Android device boots up

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_boot_receiver