CollectionBase<TModel extends DocumentBase> class
abstract
Define a collection model that includes DocumentBase as an element.
Any changes made locally in the app will be notified and related objects will reflect the changes.
When changes are reflected, notifyListeners will notify all listeners of the changes.
Define CollectionBase.create to describe the process of creating a new document.
By defining modelQuery, you can specify settings for loading, such as collection paths and conditions.
The collection implements List, but changing an element is Unmodifiable
and will result in an error.
Execute DocumentBase.save for each document to change elements, and DocumentBase.delete for each document to delete them.
To add elements, run CollectionBase.create to create a new document, then save it with DocumentBase.save.
DocumentBaseを要素に含めたコレクションモデルを定義します。
アプリのローカル内での変更はすべて通知され関連のあるオブジェクトは変更内容が反映されます。
変更内容が反映された場合notifyListenersによって変更内容がすべてのリスナーに通知されます。
CollectionBase.createを定義することで新規にドキュメントを作成する処理を記述します。
modelQueryを定義することで、コレクションのパスや条件など読み込みを行うための設定を指定できます。
コレクションはListを実装していますが、要素の変更はUnmodifiable
となりエラーになります。
要素を変更する場合は各ドキュメントのDocumentBase.saveを実行し、削除する場合は各ドキュメントのDocumentBase.deleteを実行してください。
要素を追加する場合はCollectionBase.createを実行し新しいドキュメントを作成したあと、DocumentBase.saveで保存してください。
- Inheritance
-
- Object
- ChangeNotifier
- CollectionBase
- Implemented types
-
- List<
TModel>
- List<
- Implementers
- Available extensions
Constructors
-
CollectionBase(CollectionModelQuery _modelQuery, [List<
TModel> ? value]) - Define a collection model that includes DocumentBase as an element.
-
CollectionBase.unrestricted(CollectionModelQuery _modelQuery, [List<
TModel> ? value]) - Define a collection model that includes DocumentBase as an element.
Properties
- canNext → bool
-
If the number of elements is limited by ModelQueryFilterType.limit, returns
true
if the next element can be added.no setter - databaseQuery → ModelAdapterCollectionQuery
-
Database queries for collections.
no setter
- first ↔ TModel
-
The first element.
getter/setter pairoverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isEmpty → bool
-
Whether this collection has no elements.
no setteroverride
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setteroverride
-
iterator
→ Iterator<
TModel> -
A new
Iterator
that allows iterating the elements of thisIterable
.no setteroverride - last ↔ TModel
-
The last element.
getter/setter pairoverride
- length ↔ int
-
The number of objects in this list.
getter/setter pairoverride
- loaded → bool
-
Returns
true
if the data was successfully loaded by the load method.no setter -
loading
→ Future<
CollectionBase< ?TModel> > -
If load, reload or next is executed, it waits until the reading process is completed.
no setter
- modelQuery → CollectionModelQuery
-
Query to read and save collections.
no setter
-
reloading
→ Future<
CollectionBase< ?TModel> > -
If reload is done, it waits until the loading process is finished.
no setter
-
reversed
→ Iterable<
TModel> -
An Iterable of the objects in this list in reverse order.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- single → TModel
-
Checks that this iterable has only one element, and returns that element.
no setteroverride
-
subscriptions
→ List<
StreamSubscription> -
List of currently subscribed notifications. All should be canceled when the object is destroyed.
no setter
Methods
-
add(
TModel value) → void -
This operation is not supported by an model collection.
override
-
addAll(
Iterable< TModel> iterable) → void -
This operation is not supported by an model collection.
override
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
aggregate<
TValue extends AsyncAggregateValue> (ModelAggregateQuery< TValue> query) → TValue - Get the number of elements in all collections existing in the database.
-
any(
bool test(TModel element)) → bool -
Checks whether any element of this iterable satisfies
test
.override -
asMap(
) → Map< int, TModel> -
An unmodifiable Map view of this list.
override
-
batch(
{int splitLength = 100}) → ModelBatchCollectionBuilder< TModel> - Builder for batch processing.
-
cast<
E> () → List< E> -
Returns a view of this list as a list of
R
instances.override -
clear(
) → void -
This operation is not supported by an model collection.
override
-
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element
.override -
create(
[String? id]) → TModel -
Create a new document of type
TModel
from the contents of the collection. -
deleteAll(
) → Future< CollectionBase< TModel> > - Delete all retained documents.
-
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
-
elementAt(
int index) → TModel -
Returns the
index
th element.override -
every(
bool test(TModel element)) → bool -
Checks whether every element of this iterable satisfies
test
.override -
expand<
E> (Iterable< E> f(TModel element)) → Iterable<E> -
Expands each element of this Iterable into zero or more elements.
override
-
fillRange(
int start, int end, [TModel? fillValue]) → void -
This operation is not supported by an model collection.
override
-
filterOnDidLoad(
List< TModel> value) → Future<List< TModel> > - Callback called after loading.
-
firstWhere(
bool test(TModel element), {TModel orElse()?}) → TModel -
The first element that satisfies the given predicate
test
.override -
fold<
E> (E initialValue, E combine(E previousValue, TModel element)) → E -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
override
-
followedBy(
Iterable< TModel> other) → Iterable<TModel> -
Creates the lazy concatenation of this iterable and
other
.override -
forEach(
void f(TModel element)) → void -
Invokes
action
on each element of this iterable in iteration order.override -
fromMap(
Map< String, DynamicMap> map, int? limit) → Future<List< TModel> > -
Creates a List<TModel> from a
map
of type Map<String, DynamicMap> decoded from Json. -
getRange(
int start, int end) → Iterable< TModel> -
Creates an Iterable that iterates over a range of elements.
override
-
handledOnUpdate(
ModelUpdateNotification update) → Future< void> - Describe the callback process to pass to ModelAdapterCollectionQuery.callback.
-
indexOf(
TModel element, [int start = 0]) → int -
The first index of
element
in this list.override -
indexWhere(
bool test(TModel element), [int start = 0]) → int -
The first index in the list that satisfies the provided
test
.override -
insert(
int index, TModel element) → void -
This operation is not supported by an model collection.
override
-
insertAll(
int index, Iterable< TModel> iterable) → void -
This operation is not supported by an model collection.
override
-
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
override
-
lastIndexOf(
TModel element, [int? start]) → int -
The last index of
element
in this list.override -
lastIndexWhere(
bool test(TModel element), [int? start]) → int -
The last index in the list that satisfies the provided
test
.override -
lastWhere(
bool test(TModel element), {TModel orElse()?}) → TModel -
The last element that satisfies the given predicate
test
.override -
load(
) → Future< CollectionBase< TModel> > - Reads the collection corresponding to modelQuery.
-
loadRequest(
) → Future< Map< String, DynamicMap> ?> - Implement internal processing when load, reload, or next is executed.
-
map<
E> (E f(TModel e)) → Iterable< E> -
The current elements of this iterable modified by
toElement
.override -
next(
) → Future< CollectionBase< TModel> > - If the number of elements is limited by ModelQueryFilterType.limit, additional elements are loaded for the next limited number.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
reduce(
TModel combine(TModel value, TModel element)) → TModel -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
override
-
reload(
) → Future< CollectionBase< TModel> > - Reload the collection corresponding to modelQuery.
-
remove(
Object? value) → bool -
This operation is not supported by an model collection.
override
-
removeAt(
int index) → TModel -
This operation is not supported by an model collection.
override
-
removeLast(
) → TModel -
This operation is not supported by an model collection.
override
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeRange(
int start, int end) → void -
This operation is not supported by an model collection.
override
-
removeWhere(
bool test(TModel element)) → void -
This operation is not supported by an model collection.
override
-
replaceQuery(
CollectionModelQuery callback(CollectionModelQuery source)) → Future< CollectionBase< TModel> > -
callback
will redefine a new CollectionModelQuery and execute reload. -
replaceRange(
int start, int end, Iterable< TModel> replacement) → void -
This operation is not supported by an model collection.
override
-
retainWhere(
bool test(TModel element)) → void -
This operation is not supported by an model collection.
override
-
setAll(
int index, Iterable< TModel> iterable) → void -
This operation is not supported by an model collection.
override
-
setRange(
int start, int end, Iterable< TModel> iterable, [int skipCount = 0]) → void -
This operation is not supported by an model collection.
override
-
shuffle(
[Random? random]) → void -
This operation is not supported by an model collection.
override
-
singleWhere(
bool test(TModel element), {TModel orElse()?}) → TModel -
The single element that satisfies
test
.override -
skip(
int n) → Iterable< TModel> -
Creates an Iterable that provides all but the first
count
elements.override -
skipWhile(
bool test(TModel value)) → Iterable< TModel> -
Creates an
Iterable
that skips leading elements whiletest
is satisfied.override -
sort(
[int compare(TModel a, TModel b)?]) → void -
This operation is not supported by an model collection.
override
-
sublist(
int start, [int? end]) → List< TModel> -
Returns a new list containing the elements between
start
andend
.override -
take(
int n) → Iterable< TModel> -
Creates a lazy iterable of the
count
first elements of this iterable.override -
takeWhile(
bool test(TModel value)) → Iterable< TModel> -
Creates a lazy iterable of the leading elements satisfying
test
.override -
toList(
{bool growable = true}) → List< TModel> -
Creates a List containing the elements of this Iterable.
override
-
toSet(
) → Set< TModel> -
Creates a Set containing the same elements as this iterable.
override
-
toString(
) → String -
A string representation of this object.
override
-
transaction(
) → ModelTransactionCollectionBuilder< TModel> - Builder for transactions.
-
watch(
RefHasApp ref) → TController -
Available on TController, provided by the ListenableQueryExtensions extension
-
where(
bool test(TModel element)) → Iterable< TModel> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test
.override -
whereType<
E> () → Iterable< E> -
Creates a new lazy Iterable with all elements that have type
T
.override
Operators
-
operator +(
List< TModel> other) → List<TModel> -
Returns the concatenation of this list and
other
.override -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → TModel -
The object at the given
index
in the list.override -
operator []=(
int index, TModel value) → void -
This operation is not supported by an model collection.
override