Docs Menu

Custom User Data - Flutter SDK

On this page

  • Before You Begin
  • Read a User's Custom User Data

You can store arbitrary custom data about your users with Atlas App Services. For example, you might store a user's preferred language, date of birth, or local timezone. Before writing and reading this data, you must enable custom user data in the backend. To learn more, see Enable Custom User Data.

Important

Currently you can only read custom user data with the Flutter SDK. In a future update to the SDK, you will be able to write custom user data from the SDK as well.

You can create, update, or delete custom user data using one of the other Realm SDKs, with App Services functions, or by directly querying MongoDB Atlas.

To use custom user data, you must first enable custom user data on the Atlas App Services:

  1. Create a App.
  2. Enable custom user data.

You retrieve custom user data in the User.customData property of a logged in user:

final customUserData = user.customData;

Atlas App Services does not dynamically update the value of the User.customData immediately when underlying data changes. Instead, Atlas App Services fetches the most recent version of custom user data whenever a user refreshes their access token or when you explicitly call User.refreshCustomData(), which ensures your app has the latest custom user data.

// refreshCustomData() returns the updated custom data object
final updatedCustomData = await user.refreshCustomData();
// Now when you access User.customData it's the value
// returned from User.refreshCustomData()
←  Link User Identities - Flutter SDKDevice Sync - Flutter SDK →
Give Feedback
© 2022 MongoDB, Inc.

About

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