Docs Menu

Open a Synced Realm - Flutter SDK

On this page

  • Before You Begin
  • Open a Synced Realm
  • Configure a Realm
  • Close a Realm
  • Further Reading

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:

  1. Configure Flexible Sync on the backend. You must configure Flexible Sync in the backend before you can use it with your client application.
  2. Initialize the App client.
  3. Authenticate a user in your client project.

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.

realm.close();
  • Manage a Sync Session: Learn how to add, modify, and remove sync subscriptions once you've opened a synced realm.
←  Device Sync - Flutter SDKManage a Sync Session - Flutter SDK →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.