Skip to content

(DOCSP-39501): Consolidate Quick Start page #3280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions source/frameworks/flutter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
Build with Flutter
==================

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol
.. toctree::
:titlesonly:

Placeholder page for information about building with Flutter. (This may
be a directory depending on how much content we have/need.)
Quick Start </frameworks/flutter/quick-start>
110 changes: 110 additions & 0 deletions source/frameworks/flutter/quick-start.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
.. _frameworks-flutter-quick-start:

========================
Quick Start with Flutter
========================

.. meta::
:description: Get started using Atlas Device SDK with Flutter in a Flutter application.
:keywords: Realm, Flutter, Flutter SDK, code example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need Flutter also here, right?

Suggested change
:keywords: Realm, Flutter, Flutter SDK, code example
:keywords: Realm, Flutter SDK, code example


.. facet::
:name: genre
:values: tutorial

.. facet::
:name: programming_language
:values: dart

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

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
:ref:`sdks-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
:ref:`sdks-install`.
Comment on lines +39 to +41
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Install the ``realm`` package for use in Flutter applications. For more
information about installing the SDK in a Flutter project, refer to
:ref:`sdks-install`.
:ref:`Install the Flutter SDK <sdks-install>`. Flutter applications
use the ``realm`` SDK package.


Import the SDK
--------------

Import the ``realm`` package into any files where you use it.

.. code-block:: dart
:caption: ExampleFile.dart

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 :flutter-sdk:`RealmObjectBase <realm/RealmObjectBase-mixin.html>`
class that's used within your application.

For more information, refer to :ref:`Define an Object Schema
<sdks-define-object-schema>`.

.. procedure::

.. step:: Create a Model Class

Add an SDK model class. Give your class a private name
(starting with ``_``), such as a file ``car.dart`` with a class
``_Car``.

.. literalinclude:: /examples/generated/flutter/car.snippet.define-model-flutter.dart
:language: dart
:caption: car.dart

.. step:: Generate an SDK Object Class

Generate a RealmObject class ``Car`` from the data model class ``_Car``:

.. code-block::

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.

.. step:: Watch for Changes to the Model (Optional)

You can watch your data model class to generate a new ``Car`` class
whenever there's a change to ``_Car``:

.. code-block::

dart run realm generate --watch

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 :ref:`Open a Database <sdks-quick-start-open-database>`
section.
11 changes: 3 additions & 8 deletions source/frameworks/swiftui.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
Build with SwiftUI
==================

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol
.. toctree::
:titlesonly:

Placeholder page for information about building with SwiftUI.

This will be a directory with SwiftUI content.
Quick Start </frameworks/swiftui/quick-start>
Loading
Loading