Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter : Run an app as a background service

Tags:

flutter

I want to show a custom popup message whenever the user disconnects a cellular call. The problem is how to detect when the app is not running. any leads would be helpful.

like image 454
swapnil kumar Avatar asked Jul 26 '18 13:07

swapnil kumar


People also ask

How do I run code in the background even with the screen off Flutter?

Launch app with flutter run. Switch to other app (_timerCounter value 1) Return to Flutter app (_timerCounter value 3) Pressed power button, display turned off (_timerCounter value 4)

Can I use Flutter for commercial use?

If briefly, Flutter is good for any product. Flutter is now widely used to create applications in Alibaba, Google Ads, Airbnb, Uber and other large companies. In our opinion, the framework is best suited for medium to large businesses.

What is Flutter WorkManager?

Flutter WorkManager is a wrapper around Android's WorkManager, iOS' performFetchWithCompletionHandler and iOS BGAppRefreshTask, effectively enabling headless execution of Dart code in the background. This is especially useful to run periodic tasks, such as fetching remote data on a regular basis.


1 Answers

It's been a while and there have been many developments.

First, there are some answers at How to create a service in Flutter to make an app to run always in background?

Also, flutter/Background processes will basically point you to medium/Executing Dart in the Background with Flutter Plugins and Geofencing (Sept 2018)

  • which is a Geofencing sample that involves a partnership between isolates, native Android/iOS code via MethodChannel, and PluginUtilities.getCallbackHandle (PluginUtilities)

Alas, there are many plugins available now:

  • https://pub.dev/packages/background_location
  • https://pub.dev/packages/android_alarm_manager (Android)
  • https://pub.dev/packages/background_fetch
  • https://pub.dev/packages/workmanager
  • https://pub.dev/packages/audio_service
like image 106
TWL Avatar answered Sep 21 '22 10:09

TWL