BelongsTo<E extends DataModelMixin<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
-
- Object
- Relationship<
E, E?> - BelongsTo
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 - BelongsTo.remove()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → Object?
-
Returns the value's
id
.no setter - isInitialized → bool
-
no setterinherited
- isPresent → bool
-
Whether the relationship has a value.
no setterinherited
- key → String?
-
Returns the value's
key
.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 - value ↔ E?
-
Obtains the single
E
value of this relationship (null
if not present).getter/setter pair
Methods
-
initialize(
{required DataModelMixin< DataModelMixin> owner, required String name, String? inverseName, Set<String> ? overrideKeys}) → Relationship<E, 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 -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → dynamic -
This is used to make
json_serializable
'sexplicitToJson
transparent.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
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited