HasMany<E extends DataModelMixin<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
HasMany.remove()

Properties

first → E
no setter
hashCode int
The hash code for this object.
no setterinherited
ids Set<Object>
Returns IDs in this relationship.
no setter
isEmpty bool
no setter
isInitialized bool
no setterinherited
isNotEmpty bool
no setter
isPresent bool
Whether the relationship has a value.
no setterinherited
keys Set<String>
Returns keys in this relationship.
no setter
length int
no setter
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
contains(Object? element) bool
initialize({required DataModelMixin<DataModelMixin> owner, required String name, String? inverseName, Set<String>? overrideKeys}) Relationship<E, Set<E>>
Initializes this relationship (typically when initializing the owner in DataModelMixin) by supplying the owner, and related metadata. overrideKeys ignores if the relationship was previously initialized.
inherited
map<T>(T f(E)) Iterable<T>
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
toJson() → dynamic
This is used to make json_serializable's explicitToJson transparent.
inherited
toList() List<E>
toSet() Set<E>
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>

Operators

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