DocumentBase<T> constructor

DocumentBase<T>(
  1. DocumentModelQuery modelQuery, [
  2. T? _value
])

Define a document model for storing T types that inherit from ChangeNotifier.

Any changes made locally in the app will be notified and related objects will reflect the changes.

When a value is reflected by save, delete, transaction, batch, or updated in real time from outside, all listeners are notified of the change by notifyListeners.

Define object conversion from DynamicMap to T, which is output by decoding Json by implementing DocumentBase.fromMap.

Implementing DocumentBase.toMap defines the conversion from a T object to a DynamicMap that can later be Json encoded.

By defining DocumentBase.modelQuery, you can specify settings for loading, such as document paths.

The value value can be retrieved. The value set is forbidden and should be updated using the save method.

ChangeNotifierを継承したT型を保存するためのドキュメントモデルを定義します。

アプリのローカル内での変更はすべて通知され関連のあるオブジェクトは変更内容が反映されます。

savedeletetransactionbatchでの値反映、外部からのリアルタイム更新が行われた場合notifyListenersによって変更内容がすべてのリスナーに通知されます。

DocumentBase.fromMapを実装することでJsonをデコードして出力されるDynamicMapからTへのオブジェクト変換を定義します。

DocumentBase.toMapを実装することでTのオブジェクトから後にJsonエンコード可能なDynamicMapへの変換を定義します。

DocumentBase.modelQueryを定義することで、ドキュメントのパスなど読み込みを行うための設定を指定できます。

value値を取得できます。valueのセットは禁止されており、saveメソッドで更新を行ないます。

Implementation

DocumentBase(this.modelQuery, [this._value])
    : assert(
        !(modelQuery.path.trimQuery().trimString("/").splitLength() <= 0 ||
            modelQuery.path.trimQuery().trimString("/").splitLength() % 2 !=
                0),
        "The query path hierarchy must be an even number: ${modelQuery.path}",
      );