How to create a service in Flutter to make an app

2019-04-01 03:10发布

I would like to make my Flutter application to run always in background. With android, we have to create a Service that runs always in background. I don't find something about Services in the Flutter documentation.

Is it possible to do this kind of things with Flutter?

1条回答
Evening l夕情丶
2楼-- · 2019-04-01 04:00

There isn't a way to do this directly from flutter right now although that may change at some point - see this bug/feature request. You do have a couple of options though.

The first is to use MethodChannels and simply write the android code you want to create a background service (or if you want it to always be a background service you can probably do that without needing communication from the flutter side).

The second is some combination of these two plugins - android_alarm_manager and android_intent. But that won't help for all use-cases.

查看更多
登录 后发表回答