BelongsTo<E extends DataModel<E>> class

A Relationship that models a to-one ownership.

Example: A book that belongs to an author

class Book with DataModel<Book> {
 @override
 final int id;
 final String title;
 final BelongsTo<Author> author;

 Todo({this.id, this.title, this.author});
}
Inheritance

Constructors

BelongsTo([E? model])
Creates a BelongsTo relationship, with an optional initial E model.
BelongsTo.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
id String?
no setter
ids Set<String>
no setterinherited
internalType String
no setterinherited
isEmpty bool
no setterinherited
isInitialized bool
getter/setter pairinherited
isNotEmpty bool
no setterinherited
key String?
Returns the value's key
no setter
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
value ↔ E?
Obtains the single E value of this relationship (null if not present).
getter/setter pair

Methods

add(E value, {bool notify = true}) bool
Add a value to this Relationship
inherited
addInverse(String inverseName, DataModel<DataModel> model) → void
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, E?>>
Initializes this relationship (typically when initializing the owner in DataModel) by supplying the owner, and related adapters and metadata.
override
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<E?>
Returns a StateNotifier which emits the latest value of this BelongsTo relationship.
override
where(bool test(E)) Iterable<E>
inherited

Operators

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