-
Notifications
You must be signed in to change notification settings - Fork 89
(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
dacharyc
merged 18 commits into
mongodb:feature-consolidated-sdk-docs
from
dacharyc:DOCSP-39501
Jun 18, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5012a87
Draft consolidated Quick Start page
dacharyc 6369ee1
Fix snooty build error
dacharyc 1c5d85f
Add Flutter quick start details
dacharyc 47a7c8e
Minor fixes
dacharyc 2c7eda4
Minor fix on SwiftUI Quick Start page
dacharyc 82dc27b
Port the Unity quick start over to the consolidated docs
dacharyc 1d058bb
Rename file
dacharyc e2cfc87
Reduce Unity quick start page depth due to tab OTP issues
dacharyc 6942369
Port LiveData quick start to Android section
dacharyc 8f45456
Apply suggestions from review
dacharyc 65388f4
Apply suggestions from review
dacharyc f150feb
Apply review suggestions
dacharyc 70ec4ab
Apply suggestions from review
dacharyc dd0e45f
Fix underline/overline after changing page name
dacharyc d3414b9
Remove LiveData quick start
dacharyc 3d18e0d
Remove Java SDK info from Quick Start page
dacharyc ce1a360
Move the callout
dacharyc 5d39838
Update source/includes/api-details/swift/quick-start/quick-start-impo…
dacharyc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||||||||||||
|
||||||||||||
.. 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?