How to use the background process task in Flutter

If you want to run some tasks in a period and whatever your app in background or not, you can use the flutter_workmanager plugin!

But before you use it, you need to do some settings on Android and iOS. For Android settings, I think they missed something, I also spent more time and find the solution. After you have done all of the plugin guidelines, if your Android still can’t work, please try below steps:

  1. Upgrade your project to support ‘kotlin’ , this is not a must step, but the plugin is developed by kotlin, if you still want to use java language, you can try this.
  2. Update ‘android/build.gradle‘ file, set the ‘kotlin_version’ to 1.3.0 as below:
buildscript {
    ext.kotlin_version = '1.3.0'
    repositories {
        google()
        jcenter()
    }
  ...
}

and add the dependencies:

Do you want to be a good trading in cTrader?   >> TRY IT! <<
dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.android.gms:play-services-basement:17.0.0'
    }

update the subprojects:

subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "27.1.1"
                }

                if (details.requested.group == 'androidx.core'
                        && !details.requested.name.contains('androidx') ) {
                    details.useVersion "1.0.1"
                }


            }
        }
    }

after that, you should can use the plugin on Android!

But there are some limitations on iOS, it can’t control when will trigger the background task, it just control by iOS, so we just can test and debug this by Xcode, and actually, I tried on my iPhone device, but still can’t see the task to be trigger, so I also want to know whether is working on iOS 🙁

Loading

Views: 21
Total Views: 505 ,

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome content in your inbox.

We don’t spam! Read our privacy policy for more info.

Oh hi there 👋 It’s nice to meet you.

Sign up to receive awesome content in your inbox.

We don’t spam! Read our privacy policy for more info.

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Thank you so much!