value property
E?
value
Obtains the single E
value of this relationship (null
if not present).
Implementation
E? get value => _iterable.isNotEmpty ? _iterable.first : null;
void
value=(E? newValue)
Sets the single E
value of this relationship, replacing any previous value.
Passing in null
will remove the existing value from the relationship.
Implementation
set value(E? newValue) {
final isAddition = value == null && newValue != null;
final isUpdate = value != null && newValue != null;
final isRemoval = value != null && newValue == null;
if (isRemoval || isUpdate) {
super._remove(value!, notify: false);
}
if (isAddition || isUpdate) {
super._add(newValue, notify: false);
}
// handle events
DataGraphEventType? eventType;
if (isAddition) eventType = DataGraphEventType.addEdge;
if (isUpdate) eventType = DataGraphEventType.updateEdge;
if (isRemoval) eventType = DataGraphEventType.removeEdge;
if (eventType != null) {
_graph._notify(
[_ownerKey!, if (newValue != null) newValue._key!],
metadata: _name,
type: eventType,
);
}
assert(_iterable.length <= 1);
}