This page describes how to open a synced realm using Atlas Device Sync. To learn how to open and configure non-synced realms, see Open and Close a Realm.
Before you open a realm with Flexible Sync in a Flutter application:
To open a synced realm, pass a logged in user, a list of Realm object schemas, and additional optional parameters to the Configuration.flexibleSync() constructor. Then, pass the configuration to Realm() to open an instance of the realm.
User currentUser = await app.logIn(credentials); Configuration config = Configuration.flexibleSync( currentUser, [Tricycle.schema], path: 'flex.realm'); Realm realm = Realm(config);
Once you open a synced realm, configure and manage the sync session.
For more information on additional configuration options, refer to Configure a Realm.
Once you've finished working with a synced realm, close it to prevent memory leaks.
- Manage a Sync Session: Learn how to add, modify, and remove sync subscriptions once you've opened a synced realm.