Giter VIP home page Giter VIP logo

flutter-android-background's Introduction

How to keep Flutter apps running in background on Android

This is a sample project that acts as a companion for an article that I wrote talking about some techniques to keep Flutter apps running. If you are interested you can find the article here: https://medium.com/@ppicas/keep-flutter-running-background-on-android-6ffc85be0234

App features

This is simple Flutter app that when it's opened it will show a screen with a counter that it's incremented every second. The interesting thing is that the counter never stops counting. No matter if you remove the app from recent apps or Android system kills the process to reclaim more memory. The app always recovers from any situation and keeps counting. Just uninstall the app if you want to stop it.

These are the techniques used by this project to keep Flutter running:

  • Use of moveTaskToBack to survive when back button is pressed.
  • Creation of a foreground service to increase process priority.
  • Start and stop a new Isolate to run Dart background code when FlutterActivity is destroyed.

How to run the project

  • Follow Get Started tutorial and install Flutter
  • Start and Android emulator
  • Run the app from terminal with flutter run

flutter-android-background's People

Contributors

ppicas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.