How to run background tasks in flutter?

3,434 views
Skip to first unread message

Alihaydar Gubatov

unread,
Nov 12, 2018, 7:30:09 PM11/12/18
to Flutter Dev
I know about packages like flutter-local-notifications or android-alarm-manager but those are a bit hard to set up and very buggy. How it is ever possible that a mobile framework that Google supports doesn't even have mechanism for running background tasks?

Alihaydar Gubatov

unread,
Nov 12, 2018, 7:34:39 PM11/12/18
to Flutter Dev
P.S. I know that Flutter Team provided some example how we can do it. But they seem like a hack rather than concrete solution. If I'm writing the code in flutter I shouldn't touch any Java or Swift code. That's the purpose of the Flutter right?!

Matt Carroll

unread,
Nov 12, 2018, 8:20:10 PM11/12/18
to gubatova...@gmail.com, Ben Konyi, flutt...@googlegroups.com
The method described by +Ben Konyi is currently the available solution.  I assume that's the approach you're referring to.

That said, a more holistic solution is being designed.  There are numerous use-cases that must be handled by any background execution solution so it's a non-trivial problem to solve for developers in general.

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jagannathan Srinivasan

unread,
Nov 13, 2018, 12:31:28 AM11/13/18
to mattc...@google.com, gubatova...@gmail.com, bko...@google.com, flutt...@googlegroups.com
Which is the solution from Ben Konyi that's being referred to here? I have used android-alarm-manager but it seems very unpredictable as to when the alarms trigger. Though android-alarm-manager claims to run the callback in an isolate, the callback stops firing all of a sudden. I tried with different alarm frequencies but everytime the call back fires for some time and then for no apparent reason

Jagannathan Srinivasan

unread,
Nov 13, 2018, 12:32:11 AM11/13/18
to mattc...@google.com, gubatova...@gmail.com, bko...@google.com, flutt...@googlegroups.com
Sorry hit the send button early...

On Tue, Nov 13, 2018 at 11:00 AM Jagannathan Srinivasan <jagan.sr...@gmail.com> wrote:
Which is the solution from Ben Konyi that's being referred to here? I have used android-alarm-manager but it seems very unpredictable as to when the alarms trigger. Though android-alarm-manager claims to run the callback in an isolate, the callback stops firing all of a sudden. I tried with different alarm frequencies but everytime the call back fires for some time and then for no apparent reason it stops firing. 

Matt Carroll

unread,
Nov 13, 2018, 12:33:50 AM11/13/18
to jagan.sr...@gmail.com, gubatova...@gmail.com, Ben Konyi, flutt...@googlegroups.com

Jagannathan Srinivasan

unread,
Nov 13, 2018, 12:41:21 AM11/13/18
to mattc...@google.com, gubatova...@gmail.com, bko...@google.com, flutt...@googlegroups.com
Thanks for sharing this. I had already read up this article when the background execution capability was first published. I feel this is too heavy to implement a simple callback. I have a requirement to have a background job that triggers once every 24 hours and I'm not able to achieve that successfully.

I'll again try using this heavyweight method but I agree with Alihaydar about why such a basic capability is lacking in such an awesome framework pushed by Google themselves

Michael Dudek

unread,
Nov 13, 2018, 2:10:24 AM11/13/18
to Flutter Dev
There is no way to implement general background task execution support. App background execution possibilities are strongly dependent on OS (Android/iOS).

Sarosh Tariq

unread,
Jan 22, 2019, 6:27:32 AM1/22/19
to Flutter Dev
Exactly my point. They should have released something at the launch.Most apps can't work without background execution.

Şükriye Ludwig

unread,
Jun 4, 2019, 3:16:09 AM6/4/19
to Flutter Development (flutter-dev)

hello developers, 

Is this the only way to start a background process via flutter?
What I need is a background process which is be able to listen to a grpc service and wake up the app and show the incoming message as a local push notification. Can anybody help  or give an advice?

Thank you
Cheers,
Şükriye

Jd khan

unread,
Nov 5, 2019, 6:14:07 PM11/5/19
to Flutter Development (flutter-dev)
Hi, did you manage to make the background process?

Spandan Bhandari

unread,
Nov 6, 2019, 1:09:49 AM11/6/19
to Flutter Development (flutter-dev)


On Tuesday, November 13, 2018 at 6:15:09 AM UTC+5:45, Alihaydar Gubatov wrote:
I know about packages like flutter-local-notifications or android-alarm-manager but those are a bit hard to set up and very buggy. How it is ever possible that a mobile framework that Google supports doesn't even have mechanism for running background tasks?

Try platform-channel
1. Method channel
2. Event channel
 dart to android
 android to dart
I am also doing the same thing or working on same kind of project based on geofencing
References which might help you guys:
The Boring Flutter Development Show, Episode 6: Packages and plugins is a YouTube video showing a Flutter plugin being implemented, live, using platform channels.(https://www.youtube.com/watch?v=ht2bDlJd2c4&feature=youtu.be)

Thank you

Ian Perera

unread,
Nov 7, 2019, 10:28:36 AM11/7/19
to Flutter Development (flutter-dev)
I'm using the plugging 

background_fetch: ^0.3.2

regards

Saul Palenzuela Hdez

unread,
Apr 29, 2020, 7:22:34 PM4/29/20
to Flutter Development (flutter-dev)
Ian Perera: had you made background_fetch worked evens the de app was closed or device was restarted???
Reply all
Reply to author
Forward
0 new messages