Skip to content

Commit 0e0a2e3

Browse files
authored
Merge branch 'feature-consolidated-sdk-docs' into DOCSP-39526
2 parents 954b7bc + c33fc22 commit 0e0a2e3

File tree

80 files changed

+2673
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2673
-36
lines changed

source/frameworks/flutter.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
Build with Flutter
55
==================
66

7-
.. contents:: On this page
8-
:local:
9-
:backlinks: none
10-
:depth: 2
11-
:class: singlecol
7+
.. toctree::
8+
:titlesonly:
129

13-
Placeholder page for information about building with Flutter. (This may
14-
be a directory depending on how much content we have/need.)
10+
Quick Start </frameworks/flutter/quick-start>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
.. _frameworks-flutter-quick-start:
2+
3+
========================
4+
Quick Start with Flutter
5+
========================
6+
7+
.. meta::
8+
:description: Get started using Atlas Device SDK with Flutter in a Flutter application.
9+
:keywords: Realm, Flutter, Flutter SDK, code example
10+
11+
.. facet::
12+
:name: genre
13+
:values: tutorial
14+
15+
.. facet::
16+
:name: programming_language
17+
:values: dart
18+
19+
.. contents:: On this page
20+
:local:
21+
:backlinks: none
22+
:depth: 2
23+
:class: singlecol
24+
25+
This quick start demonstrates how to use Atlas Device SDK with Flutter in a
26+
Flutter application.
27+
28+
.. tip:: Flutter Project or Standalone Dart Project?
29+
30+
This quick start contains information for using the SDK in a Flutter
31+
project. The package that you import and the way you create object
32+
models differs when using the SDK in a standalone Dart project. For
33+
a quick start using a standalone Dart project, refer to
34+
:ref:`sdks-quick-start`.
35+
36+
Install the SDK
37+
---------------
38+
39+
Install the ``realm`` package for use in Flutter applications. For more
40+
information about installing the SDK in a Flutter project, refer to
41+
:ref:`sdks-install`.
42+
43+
Import the SDK
44+
--------------
45+
46+
Import the ``realm`` package into any files where you use it.
47+
48+
.. code-block:: dart
49+
:caption: ExampleFile.dart
50+
51+
import 'package:realm/realm.dart';
52+
53+
Define Your Object Model
54+
------------------------
55+
56+
Your application's **data model** defines the structure of data stored within
57+
the database. You can define your application's data model via Dart
58+
classes in your application code with an SDK object schema.
59+
You then have to generate the :flutter-sdk:`RealmObjectBase <realm/RealmObjectBase-mixin.html>`
60+
class that's used within your application.
61+
62+
For more information, refer to :ref:`Define an Object Schema
63+
<sdks-define-object-schema>`.
64+
65+
.. procedure::
66+
67+
.. step:: Create a Model Class
68+
69+
Add an SDK model class. Give your class a private name
70+
(starting with ``_``), such as a file ``car.dart`` with a class
71+
``_Car``.
72+
73+
.. literalinclude:: /examples/generated/flutter/car.snippet.define-model-flutter.dart
74+
:language: dart
75+
:caption: car.dart
76+
77+
.. step:: Generate an SDK Object Class
78+
79+
Generate a RealmObject class ``Car`` from the data model class ``_Car``:
80+
81+
.. code-block::
82+
83+
dart run realm generate
84+
85+
Running this creates a ``Car`` class in a ``car.realm.dart`` file
86+
located in the directory where you defined the model class. This ``Car``
87+
class is public and part of the same library as the ``_Car`` data model
88+
class. The generated ``Car`` class is what's used throughout your
89+
application.
90+
91+
.. step:: Watch for Changes to the Model (Optional)
92+
93+
You can watch your data model class to generate a new ``Car`` class
94+
whenever there's a change to ``_Car``:
95+
96+
.. code-block::
97+
98+
dart run realm generate --watch
99+
100+
Perform CRUD Operations and More
101+
--------------------------------
102+
103+
Installing the library and the commands to generate the models are specific
104+
to using the SDK with a Flutter project or a standalone Dart project. But
105+
all the other operations, from reading and writing data to syncing data across
106+
devices, are the same for a Flutter or standalone Dart project.
107+
108+
To learn more about performing these operations, refer to the main Quick Start.
109+
Shared content starts with the :ref:`Open a Database <sdks-quick-start-open-database>`
110+
section.

source/frameworks/swiftui.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
Build with SwiftUI
55
==================
66

7-
.. contents:: On this page
8-
:local:
9-
:backlinks: none
10-
:depth: 2
11-
:class: singlecol
7+
.. toctree::
8+
:titlesonly:
129

13-
Placeholder page for information about building with SwiftUI.
14-
15-
This will be a directory with SwiftUI content.
10+
Quick Start </frameworks/swiftui/quick-start>

0 commit comments

Comments
 (0)