DocumentBase<T> class
abstract
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
型を保存するためのドキュメントモデルを定義します。
アプリのローカル内での変更はすべて通知され関連のあるオブジェクトは変更内容が反映されます。
saveやdelete、transaction、batchでの値反映、外部からのリアルタイム更新が行われた場合notifyListenersによって変更内容がすべてのリスナーに通知されます。
DocumentBase.fromMapを実装することでJsonをデコードして出力されるDynamicMapからT
へのオブジェクト変換を定義します。
DocumentBase.toMapを実装することでT
のオブジェクトから後にJsonエンコード可能なDynamicMapへの変換を定義します。
DocumentBase.modelQueryを定義することで、ドキュメントのパスなど読み込みを行うための設定を指定できます。
- Inheritance
-
- Object
- ChangeNotifier
- DocumentBase
- Implemented types
-
- ValueListenable<
T?>
- ValueListenable<
- Implementers
- Available Extensions
Constructors
- DocumentBase(DocumentModelQuery modelQuery, [T? _value])
-
Define a document model for storing
T
types that inherit from ChangeNotifier. - DocumentBase.unrestricted(DocumentModelQuery modelQuery, [T? _value])
-
Define a document model for storing
T
types that inherit from ChangeNotifier.
Properties
- databaseQuery → ModelAdapterDocumentQuery
-
Database queries for documents.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- loaded → bool
-
Returns
true
if the data was successfully loaded by the load method.no setter -
loading
→ Future<
T?> ? -
If load or reload is executed, it waits until the loading process is completed.
no setter
- modelQuery → DocumentModelQuery
-
Query for loading and saving documents.
final
-
reloading
→ Future<
T?> ? -
If reload is done, it waits until the loading process is finished.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
saving
→ Future<
void> ? -
If save or delete is executed, it waits until the read process is completed.
no setter
-
subscriptions
→ List<
StreamSubscription> -
List of currently subscribed notifications. All should be canceled when the object is destroyed.
no setter
- uid → String
-
Returns the ID for the document path.
no setter
- value → T?
-
The current value stored in this document.
no setteroverride
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
batch(
{int splitLength = 100}) → ModelBatchDocumentBuilder< T> - Builder for batch processing.
-
delete(
) → Future< void> - Data can be deleted.
-
deleteRequest(
) → Future< void> - Implement internal processing when delete is executed.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
override
-
filterOnDidLoad(
T? value) → Future< T?> - Callback called after loading.
-
filterOnLoad(
DynamicMap rawData) → DynamicMap - Implement filters when loading data.
-
filterOnSave(
DynamicMap rawData) → DynamicMap - You can filter the data to be saved.
-
fromMap(
DynamicMap map) → T -
Defines the object transformation from DynamicMap to
T
, which is output by decoding Json. -
handledOnUpdate(
ModelUpdateNotification update) → Future< void> - Describe the callback process to be passed to ModelAdapterDocumentQuery.callback.
-
load(
) → Future< T?> - Reads documents corresponding to modelQuery.
-
loadRequest(
) → Future< DynamicMap?> - Implement internal processing when load or reload is executed.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
reload(
) → Future< T?> - Reload the document corresponding to modelQuery.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
save(
T? newValue) → Future< void> - Data can be saved.
-
saveRequest(
DynamicMap map) → Future< void> - Implement internal processing when save is executed.
-
toMap(
T value) → DynamicMap -
Defines the conversion from a
T
object to a DynamicMap that can later be Json encoded. -
toString(
) → String -
A string representation of this object.
override
-
transaction(
) → ModelTransactionDocumentBuilder< T> - Builder for transactions.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited