cobi_flutter_service 1.0.3 copy "cobi_flutter_service: ^1.0.3" to clipboard
cobi_flutter_service: ^1.0.3 copied to clipboard

PlatformAndroid

An implementation of services for Flutter.

CobiFlutterService plugin #

This executes dart code in a second isolate while providing communication between the main and background isolates.

It also integrates with the device's status bar.

This plugin is currently only available for Android.

Usage #

To use this plugin, add cobi_flutter_service as a dependency in your pubspec.yaml file.

Then implement a runner function:

void serviceRunner(SendPort sendPort, ReceivePort receivePort) {
  print("Service runner executed");
}

To prepare your app to run the background service, initialize it:

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  CobiFlutterService.instance.initService(serviceRunner, true);
  runApp(MyApp());
}

Then you can start the service by calling

CobiFlutterService.instance.startService();

For a more advanced use case, see the included example

0
likes
140
points
41
downloads

Publisher

unverified uploader

Weekly Downloads

An implementation of services for Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

cobi_flutter_service_android, cobi_flutter_service_platform_interface, flutter

More

Packages that depend on cobi_flutter_service