|
| 1 | +:orphan: |
| 2 | + |
| 3 | +.. _flutter-upgrade-v2: |
| 4 | + |
| 5 | +============================= |
| 6 | +Upgrade to Flutter SDK v2.0.0 |
| 7 | +============================= |
| 8 | + |
| 9 | +.. meta:: |
| 10 | + :description: Upgrade your existing Flutter or Dart app to Flutter SDK version 2.0.0 or later. |
| 11 | + :keywords: code example, migration, migrate |
| 12 | + |
| 13 | +.. facet:: |
| 14 | + :name: genre |
| 15 | + :values: tutorial |
| 16 | + |
| 17 | +.. contents:: On this page |
| 18 | + :local: |
| 19 | + :backlinks: none |
| 20 | + :depth: 2 |
| 21 | + :class: singlecol |
| 22 | + |
| 23 | +Atlas Device SDK for Flutter version 2.0.0 introduces several breaking changes |
| 24 | +that impact existing apps upgrading from an earlier version. |
| 25 | + |
| 26 | +Notably, this version of the SDK: |
| 27 | + |
| 28 | +- Changes the part builder and how the SDK generates files for |
| 29 | + your data model classes. This change impacts all apps upgrading from an |
| 30 | + earlier version of the SDK. Refer to the :ref:`flutter-v2-builder-breaking-changes` |
| 31 | + section on this page for information and instructions. |
| 32 | + |
| 33 | +- Removes or replaces several classes and members. These changes may or may not impact your |
| 34 | + app. Refer to the :ref:`flutter-v2-removed-classes` section |
| 35 | + on this page for information and instructions for impacted apps. |
| 36 | + |
| 37 | +.. _flutter-v2-builder-breaking-changes: |
| 38 | + |
| 39 | +Builder Changes |
| 40 | +--------------- |
| 41 | + |
| 42 | +.. important:: |
| 43 | + |
| 44 | + This change impacts all apps upgrading from an earlier version of the SDK. |
| 45 | + |
| 46 | +Flutter SDK version 2.0.0 updates the SDK's ``realm_generator`` to use a |
| 47 | +``PartBuilder`` instead of a ``SharedPartBuilder``. |
| 48 | +This updated builder generates ``RealmModel`` data model files with a new |
| 49 | +``.realm.dart`` file extension: |
| 50 | + |
| 51 | +.. list-table:: |
| 52 | + :header-rows: 1 |
| 53 | + :widths: 25 25 50 |
| 54 | + |
| 55 | + * - Version |
| 56 | + - File Extension |
| 57 | + - Example Part Directive |
| 58 | + |
| 59 | + * - SDK v2.0.0 and later |
| 60 | + - ``.realm.dart`` |
| 61 | + - .. literalinclude:: /examples/generated/flutter/migrate_parts.snippet.part-directive-new.dart |
| 62 | + :language: dart |
| 63 | + |
| 64 | + * - SDK v1.9.0 and earlier |
| 65 | + - ``.g.dart`` |
| 66 | + - .. literalinclude:: /examples/generated/flutter/migrate_parts.snippet.part-directive-old.dart |
| 67 | + :language: dart |
| 68 | + |
| 69 | +.. tip:: |
| 70 | + |
| 71 | + The update from ``SharedPartBuilder`` to ``PartBuilder`` makes it easier |
| 72 | + to use multiple builders in your app. For example, combining ``realm_dart`` |
| 73 | + with a serialization package builder such as ``dart_mappable`` or |
| 74 | + ``json_serializable``. |
| 75 | + |
| 76 | +.. _flutter-v2-what-do-i-need-to-do: |
| 77 | + |
| 78 | +What Do I Need to Do? |
| 79 | +~~~~~~~~~~~~~~~~~~~~~ |
| 80 | + |
| 81 | +When you upgrade an existing app from an earlier version of the Flutter SDK to |
| 82 | +version 2.0.0 or later, you *must* update any existing part declarations, then |
| 83 | +regenerate the object models with the new ``.realm.dart`` file extension: |
| 84 | + |
| 85 | +.. procedure:: |
| 86 | + |
| 87 | + .. step:: Update Your Existing Part Declarations |
| 88 | + |
| 89 | + Update all of the ``RealmObject`` part declarations in your app to |
| 90 | + use the new naming convention: |
| 91 | + |
| 92 | + .. literalinclude:: /examples/generated/flutter/migrate_parts.snippet.migrate-model-dart-new.dart |
| 93 | + :language: dart |
| 94 | + :emphasize-lines: 3-5 |
| 95 | + |
| 96 | + .. step:: Regenerate Your Object Models |
| 97 | + |
| 98 | + .. tabs:: |
| 99 | + |
| 100 | + .. tab:: Flutter |
| 101 | + :tabid: flutter |
| 102 | + |
| 103 | + After you update all of your declarations, regenerate your |
| 104 | + object models with the new ``.realm.dart`` file extension. |
| 105 | + You can safely delete any ``.g.dart`` files from your project. |
| 106 | + |
| 107 | + .. code-block:: |
| 108 | + |
| 109 | + dart run realm generate |
| 110 | + |
| 111 | + .. tab:: Dart Standalone |
| 112 | + :tabid: dart |
| 113 | + |
| 114 | + After you update all of your declarations, regenerate your |
| 115 | + object models with the new ``.realm.dart`` file extension. |
| 116 | + You can safely delete any ``.g.dart`` files from your project. |
| 117 | + |
| 118 | + .. code-block:: |
| 119 | + |
| 120 | + dart run realm_dart generate |
| 121 | + |
| 122 | +.. _flutter-v2-removed-classes: |
| 123 | + |
| 124 | +Removed Classes and Members |
| 125 | +--------------------------- |
| 126 | + |
| 127 | +Flutter SDK version 2.0.0 also removed or replaced several classes, members, and properties |
| 128 | +from the SDK. These changes may or may not impact your app. |
| 129 | + |
| 130 | +The following table outlines what was removed and why, as well as a recommended solution |
| 131 | +when upgrading an app that used the removed class or member, if any: |
| 132 | + |
| 133 | +.. list-table:: |
| 134 | + :header-rows: 1 |
| 135 | + :widths: 33 33 33 |
| 136 | + |
| 137 | + * - Removed Class or Member |
| 138 | + - Reason |
| 139 | + - Solution |
| 140 | + |
| 141 | + * - ``AppConfiguration.localAppName`` and ``AppConfiguration.localAppVersion`` |
| 142 | + - Unused in SDK. |
| 143 | + - Remove any instances. |
| 144 | + |
| 145 | + * - ``ClientResetError.isFatal`` |
| 146 | + - Not needed. Always ``true``. |
| 147 | + - Remove any instances. |
| 148 | + |
| 149 | + * - ``ClientResetError.sessionErrorCode`` |
| 150 | + - Consolidated into ``SyncErrorCode`` in SDK v1.6.0. |
| 151 | + - Use ``SyncErrorCode`` enum. See also the |
| 152 | + :flutter-sdk:`SyncError <realm/SyncErrorCode.html>` API reference. |
| 153 | + |
| 154 | + * - ``Realm.logger.level`` |
| 155 | + - Replaced by ``Realm.logger.setLogLevel``. |
| 156 | + - Replace any instances. See also :ref:`sdks-logging`. |
| 157 | + |
| 158 | + * - ``RealmProperty.indexed`` |
| 159 | + - Replaced by ``RealmProperty.indexType``. |
| 160 | + - Replace any instances. |
| 161 | + |
| 162 | + * - ``RealmValue.type`` |
| 163 | + - Changed to an enum of ``RealmValueType``. |
| 164 | + - Replace any instances. See also :ref:`RealmValue Data Type <sdks-mixed-data-type>`. |
| 165 | + |
| 166 | + * - ``RealmValue.uint8List`` |
| 167 | + - Renamed to ``RealmValue.binary``. |
| 168 | + - Replace any instances. See also :ref:`RealmValue Data Type <sdks-mixed-data-type>`. |
| 169 | + |
| 170 | + * - ``SchemaObject.properties`` |
| 171 | + - ``SchemaObject`` changed to an iterable collection of ``SchemaProperty``. |
| 172 | + - Replace any instances. See also the |
| 173 | + :flutter-sdk:`SchemaObject <realm/SchemaObject-class.html>` API reference. |
| 174 | + |
| 175 | + * - ``SyncError`` constructor and ``SyncError.create`` factory |
| 176 | + - Sync errors should only be created internally by the SDK. |
| 177 | + - Remove any instances. |
| 178 | + |
| 179 | + * - ``SyncClientError``, ``SyncConnectionError``, ``SyncSessionError``, |
| 180 | + ``SyncResolveError``, ``SyncWebSocketError``, and ``GeneralSyncError`` |
| 181 | + - Consolidated into ``SyncError`` in SDK v1.6.0. |
| 182 | + - Use ``SyncError`` or its subclasses. See also the |
| 183 | + :flutter-sdk:`SyncError <realm/SyncErrorCode.html>` API reference. |
| 184 | + |
| 185 | + * - ``SyncErrorCategory``, ``SyncClientErrorCode``, ``SyncConnectionErrorCode``, |
| 186 | + ``SyncSessionErrorCode``, ``SyncResolveErrorCode``,``SyncWebsocketErrorCode``, |
| 187 | + and ``GeneralSyncErrorCode`` |
| 188 | + - Consolidated into ``SyncErrorCode`` in SDK v1.6.0. |
| 189 | + - Use ``SyncErrorCode`` enum. See also the |
| 190 | + :flutter-sdk:`SyncError <realm/SyncErrorCode.html>` API reference. |
| 191 | + |
| 192 | + * - ``SyncError.codeValue``, ``SyncError.category``, and ``SyncError.detailedMessage`` |
| 193 | + - Consolidated into ``SyncError`` in SDK v1.6.0. Messages were unused. |
| 194 | + - Remove any category or message instances. Replace ``SyncError.codeValue`` |
| 195 | + with ``SyncError.code.code``. See also the |
| 196 | + :flutter-sdk:`SyncError <realm/SyncErrorCode.html>` API reference. |
| 197 | + |
| 198 | + * - ``SyncProgress.transferredBytes`` and ``SyncProgress.transferableBytes`` |
| 199 | + - Reported transferred and transferable values were incorrect. Consolidated |
| 200 | + into a new ``SyncProgress.progressEstimate`` metric. |
| 201 | + - Use ``SyncProgress.progressEstimate``. See also :ref:`sdks-check-upload-and-download-progress`. |
| 202 | + |
| 203 | + * - ``User.provider`` |
| 204 | + - Provider is associated with each identity, so value was incorrect |
| 205 | + for users with more than one identity. |
| 206 | + - Remove any instances. |
0 commit comments