Quick Start with Flutter
On this page
This quick start demonstrates how to use Atlas Device SDK with Flutter in a Flutter application.
Tip
Flutter Project or Standalone Dart Project?
This quick start contains information for using the SDK in a Flutter project. The package that you import and the way you create object models differs when using the SDK in a standalone Dart project. For a quick start using a standalone Dart project, refer to Quick Start.
Install the SDK
Install the realm
package for use in Flutter applications. For more
information about installing the SDK in a Flutter project, refer to
Install Atlas Device SDK.
Import the SDK
Import the realm
package into any files where you use it.
import 'package:realm/realm.dart';
Define Your Object Model
Your application's data model defines the structure of data stored within the database. You can define your application's data model via Dart classes in your application code with an SDK object schema. You then have to generate the RealmObjectBase class that's used within your application.
For more information, refer to Define an Object Schema.
Generate an SDK Object Class
Generate a RealmObject class Car
from the data model class _Car
:
dart run realm generate
Running this creates a Car
class in a car.realm.dart
file
located in the directory where you defined the model class. This Car
class is public and part of the same library as the _Car
data model
class. The generated Car
class is what's used throughout your
application.
Perform CRUD Operations and More
Installing the library and the commands to generate the models are specific to using the SDK with a Flutter project or a standalone Dart project. But all the other operations, from reading and writing data to syncing data across devices, are the same for a Flutter or standalone Dart project.
To learn more about performing these operations, refer to the main Quick Start. Shared content starts with the Open a Database section.