Flutter - Is there anything similar to sync adapter in flutter

1,621

Sync-adapters are core Android components. Flutter cannot directly provide a replacement for them. However, flutter does provide a mechanism to use platform specific APIs called flutter plugin. And although their are a lot of plugins already present, their is still a bit lack of plugins providing such core platform support.

Ideally, in an android application, the sync adapters are background services which can be triggered by the OS itself in a separate process, so the simplest way would be to do the following :

  1. Create a separate sync-adapter inside the android directory of your flutter app. Make sure you correctly follow all the requirements for the sync-adapter to work. The documentation is in here.

  2. Create a simple plugin-mechanism using this to invoke android APIs corresponding to the sync-adapter.

Also note that all this code - Android sync-adapter, flutter-plugin and your flutter-app, can simply reside in current code base. You are NOT REQUIRED to create a separate "plugin" to actually use the plugin.

Share:
1,621
vikas pandey
Author by

vikas pandey

I like to programing,photo editing , new Gadgets, etc...

Updated on December 15, 2022

Comments

  • vikas pandey
    vikas pandey over 1 year

    I wanted to sync my local DB with my server. In Android we have sync Adapter that does the work and make life easier. I would wonder if we have something similar in Flutter or how can I do that in flutter.