Reputation: 117
I am trying to create a project that in background if app terminated fetched data on (ios and android), without to create a external backend api server, and flutter can get this data after it is opened, and opposite native get data from flutter, after saving data in the database.
Anyone has an idea about what should I use to do this, or to create a database communication between flutter and native (ios and android)?
Upvotes: 0
Views: 691
Reputation: 5742
You can achieve it using https://pub.dev/packages/flutter_secure_storage
it can be done simple steps
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
// Create your storage
final mystorage = new FlutterSecureStorage();
// Read your values
String value = await mystorage.read(key: key);
// Read all values
Map<String, String> allValues = await mystorage.readAll();
// Delete value
await mystorage.delete(key: key);
// Delete all
await mystorage.deleteAll();
// Write value
await mystorage.write(key: key, value: value);
Upvotes: 1
Reputation: 184
There is a plugin called Background Fetch which might help you. It wakes up the app in the background about every 15 minutes and runs a callback. You could use the callback to fetch data from a remote database and store it in a SQLite database or as data files on the user's device. The data will be available on the device when the user reopens the app. If you need to fetch a large amount of data, maybe you should fetch the data in small batches with a flag to keep track of the last chunk of data fetched.
Upvotes: 0