HasMany<E extends DataModel<E>> class

A Relationship that models a to-many ownership.

Example: An author who has many books

class Author with DataModel<Author> {
 @override
 final int id;
 final String name;
 final HasMany<Book> books;

 Todo({this.id, this.name, this.books});
}
Inheritance

Constructors

HasMany([Set<E>? models])
Creates a HasMany relationship, with an optional initial Set<E>.
HasMany.fromJson(Map<String, dynamic> map)
For internal use with json_serializable.
factory

Properties

first → E?
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
ids Set<String>
no setterinherited
internalType String
no setterinherited
isEmpty bool
no setterinherited
isInitialized bool
getter/setter pairinherited
isNotEmpty bool
no setterinherited
keys Set<String>
Returns keys as Set in relationship if initialized, otherwise an empty set
no setterinherited
length int
no setterinherited
props List<Object>
The list of properties that will be used to determine whether two instances are equal.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited

Methods

add(E value, {bool notify = true}) bool
Add a value to this Relationship
inherited
contains(Object element) bool
inherited
dispose() → void
inherited
initialize({required Map<String, RemoteAdapter<DataModel>> adapters, required DataModel<DataModel> owner, required String name, String? inverseName}) Future<Relationship<E, Set<E>>>
Initializes this relationship (typically when initializing the owner in DataModel) by supplying the owner, and related adapters and metadata.
inherited
map<T>(T f(E)) Iterable<T>
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(Object value, {bool notify = true}) bool
Removes a value from this Relationship
inherited
toJson() → dynamic
This is used to make json_serializable's explicitToJson transparent.
inherited
toList() List<E>
inherited
toSet() Set<E>
inherited
toString() String
A string representation of this object.
override
watch() DelayedStateNotifier<Set<E>>
Returns a StateNotifier which emits the latest Set<E> representing this HasMany relationship.
override
where(bool test(E)) Iterable<E>
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited