FirestoreCollectionModel<T extends FirestoreDocumentModel> class
abstract
Base class for holding and manipulating data from a firestore database as a collection of FirestoreDocumentModel.
The load() method retrieves the value from the firestore database and the save() method saves the value to the firestore database.
When listen() is executed, changes in the number of elements in the Firestore collection are monitored and updated in real time.
Each document's change is notified only to the documents in it.
- Inheritance
-
- Object
- ChangeNotifier
- Model<
List< T> > - ValueModel<
List< T> > - ListModel<
T> - FirestoreCollectionModel
- Implemented types
- Implementers
- Available Extensions
Constructors
-
FirestoreCollectionModel(String path, [List<
T> ? value]) - Base class for holding and manipulating data from a firestore database as a collection of FirestoreDocumentModel.
Properties
- canNext → bool
-
Returns True if the following reads are possible
no setteroverride
- disposed → bool
-
True if the model is Disposed.
no setterinherited
- firestore → FirebaseFirestore
-
A valid Firestore instance.
no setter
- first ↔ T
-
Returns the first element.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isEmpty → bool
-
Returns
true
if there are no elements in this collection.no setterinherited - isNotEmpty → bool
-
Returns true if there is at least one element in this collection.
no setterinherited
-
iterator
→ Iterator<
T> -
Returns a new
Iterator
that allows iterating the elements of thisIterable
.no setterinherited - last ↔ T
-
Returns the last element.
getter/setter pairinherited
- length ↔ int
-
The number of objects in this list.
getter/setter pairinherited
- loaded → bool
-
It becomes
true
after loadOnce is executed.no setteroverride -
loading
→ Future<
void> ? -
Returns itself after the load finishes.
no setteroverride
- notifyOnChangeList → bool
-
If this value is true,
Notify changes when there are changes in the list itself using list-specific methods.
no setteroverride
- notifyOnChangeValue → bool
-
If this value is true,
the change will be notified when value itself is changed.
no setteroverride
- notifyOnModified → bool
-
If it is
true
, the collection itself will be notified if the content of the document has changed.no setter -
parameters
→ Map<
String, String> -
Firestore query parameters.
final
- path → String
-
Firestore collection path.
final
-
references
→ List<
Query< DynamicMap> > -
You can change the Firestore reference.
no setter
-
reversed
→ Iterable<
T> -
An Iterable of the objects in this list in reverse order.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
saving
→ Future<
void> ? -
Returns itself after the save/delete finishes.
no setteroverride
- single → T
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
-
subscriptions
→ List<
StreamSubscription> -
This is a list of real-time updates to which you are currently subscribed.
final
-
value
↔ List<
T> -
The current value stored in this notifier.
getter/setter pairinherited
Methods
-
add(
T value) → void -
Adds
value
to the end of this list, extending the length by one.inherited -
addAll(
Iterable< T> iterable) → void -
Appends all objects of
iterable
to the end of this list.inherited -
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
any(
bool test(T element)) → bool -
Checks whether any element of this iterable satisfies
test
.inherited -
append(
String uid, {T? data}) → Future< void> -
Add a new document to the current collection based on
uid
.override -
asMap(
) → Map< int, T> -
An unmodifiable Map view of this list.
inherited
-
cast<
E> () → List< E> -
Returns a view of this list as a list of
R
instances.inherited -
clear(
) → void -
Removes all objects from this list; the length of the list becomes zero.
inherited
-
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element
.inherited -
create(
[String? id]) → T -
Create a new document.
override
-
createDocument(
String path) → T - Add a process to create a document object.
-
delete(
bool test(T value)) → Future< void> -
Remove elements in the collection that are
true
intest
.override -
dependOn(
Listenable listenable, [List< T> filter(List<T> origin)?]) → void -
Sends a notification to itself when the target
listenable
is updated.inherited -
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 and removeListener will throw after the object is disposed).
override
-
elementAt(
int index) → T -
Returns the
index
th element.inherited -
every(
bool test(T element)) → bool -
Checks whether every element of this iterable satisfies
test
.inherited -
expand<
E> (Iterable< E> f(T element)) → Iterable<E> -
Expands each element of this Iterable into zero or more elements.
inherited
-
fetch(
[bool listen = true]) → Future< void> -
Provides the best data acquisition method to implement during screen build.
override
-
fillRange(
int start, int end, [T? fillValue]) → void -
Overwrites a range of elements with
fillValue
.inherited -
firstWhere(
bool test(T element), {T orElse()?}) → T -
Returns the first element that satisfies the given predicate
test
.inherited -
fold<
E> (E initialValue, E combine(E previousValue, T element)) → E -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< T> other) → Iterable<T> -
Returns the lazy concatenation of this iterable and
other
.inherited -
forEach(
void f(T element)) → void -
Applies the function
f
to each element of this collection in iteration order.inherited -
getRange(
int start, int end) → Iterable< T> -
Creates an Iterable that iterates over a range of elements.
inherited
-
indexOf(
T element, [int start = 0]) → int -
The first index of
element
in this list.inherited -
indexWhere(
bool test(T element), [int start = 0]) → int -
The first index in the list that satisfies the provided
test
.inherited -
initState(
) → void -
The method to be executed when initialization is performed.
inherited
-
insert(
int index, T element) → void -
Inserts
element
at positionindex
in this list.inherited -
insertAll(
int index, Iterable< T> iterable) → void -
Inserts all objects of
iterable
at positionindex
in this list.inherited -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastIndexOf(
T element, [int? start]) → int -
The last index of
element
in this list.inherited -
lastIndexWhere(
bool test(T element), [int? start]) → int -
The last index in the list that satisfies the provided
test
.inherited -
lastWhere(
bool test(T element), {T orElse()?}) → T -
Returns the last element that satisfies the given predicate
test
.inherited -
listen(
) → Future< void> - Load data while monitoring Firestore for real-time updates.
-
load(
) → Future< void> - Retrieves data and updates the data in the model.
-
loadOnce(
) → Future< void> - If the data is empty, load is performed only once.
-
map<
E> (E f(T e)) → Iterable< E> -
Returns a new lazy Iterable with elements that are created by
calling
f
on each element of thisIterable
in iteration order.inherited -
next(
) → Future< void> -
Load the data on the next page.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
onAppend(
) → Future< void> - Callback before the append has been done.
-
onDelete(
) → Future< void> - Callback before the delete has been done.
-
onDidAppend(
) → Future< void> - Callback after the append has been done.
-
onDidDelete(
) → Future< void> - Callback after the delete has been done.
-
onDidListen(
) → Future< void> - Callback after the listen has been done.
-
onDidLoad(
) → Future< void> - Callback after the load has been done.
-
onDidLoadNext(
) → Future< void> - Callback after the load next has been done.
-
onDidSave(
) → Future< void> - Callback after the save has been done.
-
onListen(
) → Future< void> - Callback before the listen has been done.
-
onLoad(
) → Future< void> - Callback before the load has been done.
-
onLoadNext(
) → Future< void> - Callback before the load next has been done.
-
onSave(
) → Future< void> - Callback before the save has been done.
-
query(
Query< DynamicMap> query) → Query<DynamicMap> - You can change the query object of Firestore.
-
reduce(
T combine(T value, T element)) → T -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
reload(
) → Future< void> -
Reload data and updates the data in the model.
override
-
remove(
Object? value) → bool -
Removes the first occurrence of
value
from this list.inherited -
removeAt(
int index) → T -
Removes the object at position
index
from this list.inherited -
removeLast(
) → T -
Removes and returns the last object in this list.
inherited
-
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 -
Removes a range of elements from the list.
inherited
-
removeWhere(
bool test(T element)) → void -
Removes all objects from this list that satisfy
test
.inherited -
replaceRange(
int start, int end, Iterable< T> replacement) → void -
Replaces a range of elements with the elements of
replacement
.inherited -
retainWhere(
bool test(T element)) → void -
Removes all objects from this list that fail to satisfy
test
.inherited -
save(
) → Future< void> -
Data stored in the model is stored in a database external to the app that is tied to the model.
override
-
setAll(
int index, Iterable< T> iterable) → void -
Overwrites elements with the objects of
iterable
.inherited -
setNotifyOnModified(
bool notify) → void -
If
notify
is set totrue
, the collection will be notified of changes to the document. -
setRange(
int start, int end, Iterable< T> iterable, [int skipCount = 0]) → void -
Writes some elements of
iterable
into a range of this list.inherited -
shuffle(
[Random? random]) → void -
Shuffles the elements of this list randomly.
inherited
-
singleWhere(
bool test(T element), {T orElse()?}) → T -
Returns the single element that satisfies
test
.inherited -
skip(
int n) → Iterable< T> -
Returns an Iterable that provides all but the first count elements.
inherited
-
skipWhile(
bool test(T value)) → Iterable< T> -
Returns an
Iterable
that skips leading elements whiletest
is satisfied.inherited -
sort(
[int compare(T a, T b)?]) → void -
Sorts this list according to the order specified by the
compare
function.inherited -
sublist(
int start, [int? end]) → List< T> -
Returns a new list containing the elements between
start
andend
.inherited -
take(
int n) → Iterable< T> -
Returns a lazy iterable of the count first elements of this iterable.
inherited
-
takeWhile(
bool test(T value)) → Iterable< T> -
Returns a lazy iterable of the leading elements satisfying
test
.inherited -
toList(
{bool growable = true}) → List< T> -
Creates a List containing the elements of this Iterable.
inherited
-
toNotifier<
V> (V converter(List< T> value)) → ValueNotifier<V> -
Generates a value notifier.
inherited
-
toSet(
) → Set< T> -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transaction(
[String? linkedCollectionPath]) → FirestoreCollectionTransactionBuilder -
Generate a Transaction for this collection.
override
-
where(
bool test(T element)) → Iterable< T> -
Returns a new lazy Iterable with all elements that satisfy the
predicate
test
.inherited -
whereType<
E> () → Iterable< E> -
Returns a new lazy Iterable with all elements that have type
T
.inherited
Operators
-
operator +(
List< T> other) → List<T> -
Returns the concatenation of this list and
other
.inherited -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator [](
int index) → T -
The object at the given
index
in the list.inherited -
operator []=(
int index, T value) → void -
Sets the value at the given
index
in the list tovalue
.inherited