flutter_background_service 0.2.2
flutter_background_service: ^0.2.2 copied to clipboard
A flutter plugin for executing dart code continously even application closed.
flutter_background_service #
A flutter plugin for execute dart code in background.
Android #
- No additional setting is required.
- To change notification icon, just add drawable icon with name
ic_bg_service_small.
iOS #
- Enable
background_fetchcapability in xcode (optional), if you wise ios to executeIosConfiguration.onBackgroundcallback.
Usage #
- Call
FlutterBackgroundService.configureto configure handler that will be executed by the Service. - Call
FlutterBackgroundService.startto start the Service ifautoStartis not enabled. - Since the Service using Isolates, You won't be able to share reference between UI and Service. You can communicate between UI and Service using
sendData()andonDataReceived.
FAQ #
Why the service not started automatically? #
Some android device manufacturers have a custom android os for example MIUI from Xiaomi. You have to deal with that policy.
Service killed by system and not respawn? #
Try to disable battery optimization for your app.