5164

Flutter: cross-platform way to keep application running in the background

<h3>Question</h3>

I'm trying to figure out a way to keep a Flutter application running even if it's not in focus. For instance have a countdown running and play an alarm sound/show notification on completion, no matter what's running in foreground. Can anyone point me in the right direction? Ideally something that works cross-platform.

I found this thread but it's almost 2 years old, so I'm thinking maybe there has been some development since then.


<h3>Answer1:</h3>

This looks like what you might want: https://medium.com/flutter-io/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124. It's a nice article on Medium describing how to run things in the background on both iOS and Android, especially using the most recent releases of Flutter.

The official documentation for Flutter in the background is at https://flutter.io/docs/development/packages-and-plugins/background-processes. The key is to run your code in an Isolate, because you won't have access to the GUI Isolate when you are in the background.

来源:https://stackoverflow.com/questions/53450029/flutter-cross-platform-way-to-keep-application-running-in-the-background

Recommend

  • Discrete colorbar in R plotly
  • WebView should use same cookies as fetch
  • hash_map: why it defines less, rather than equal_to
  • GET Ajax returns html code in response instead of json object
  • Custom deleters for std::shared_ptrs
  • What is the format of in git-branch --list
  • Distinction between python str and tuple objects [duplicate]
  • Lock file for access on windows
  • error using selenium chromedriver on windows 7 64 bit
  • No session share and avoid navigation buttons in browser while opening application window
  • Python SKLearn: How to Get Feature Names After OneHotEncoder?
  • Where to store user uploaded files in Django
  • Where is the buffer allocated in opencl?
  • Post hoc tests with ezANOVA output
  • Sending EoS to filesink while removing branch from tee
  • three.js — fit a background image panorama
  • Should I have different DTOs for Create and Update? (CRUD) [closed]
  • Errors with Codename One “Send iOS Build” and “Send Android Build”
  • Modification of innerHTML stored in variable not working
  • using php to create an xml file from a mysql db
  • Java: search words in two dimensional array
  • cordova edit-config not updating AndroidManifest.xml
  • Spring Mvc submit/delete checked (selected) records from table
  • MySQL - Filter records which date is biggest
  • Detect when MathJax has finished loading in UIWebView
  • How to set http status code when responding to servlet client from Filter class-method in tomcat
  • Querying Elasticsearch Address Based Index
  • How can I do case insensitive string search with Linq and SQL Server?
  • dmtracedump doesn't work, HELP!
  • UIScrollView does not restore properly
  • Optimization of optim() in R ( L-BFGS-B needs finite values of 'fn')
  • Unable to start a WebView from an AsyncTask
  • Why do you need 2 Javascript files for cross-platform Cordova plugin?
  • .Net core Hosted Services guaranteed to complete
  • C# code can't “see” the methods in my C++ dll
  • All Event listing on specified date in Google Calender api (V3) in java?
  • How to run chrome.tabs.insertCSS from the background page on each page?
  • Unable to create Access token grant type in wso2 API manager store to test API
  • What is the best way to cache and reuse immutable singleton objects in Java?
  • How to call different template for different category archive page in woocommerce