SingleOrNullSelectable<T> class
abstract
Selectable methods for returning or streaming single, nullable results.
Useful for refining the return type of a query, while still delegating whether to getSingleOrNull or watchSingleOrNull result to the consuming code.
// Retrieve a todo from an external link that may not be valid.
SingleOrNullSelectable<Todo> entryFromExternalLink(int id) {
return select(todos)..where((t) => t.id.equals(id));
}
final idFromEmailLink = 100;
entryFromExternalLink(idFromEmailLink).getSingleOrNull();
entryFromExternalLink(idFromEmailLink).watchSingleOrNull();
See also: MultiSelectable for exposing multi-value methods and SingleSelectable for exposing non-nullable value methods.
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getSingleOrNull(
) → Future< T?> -
Executes this statement, like Selectable.get, but only returns one
value. If the result too many values, this method will throw. If no
row is returned,
null
will be returned instead. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
watchSingleOrNull(
) → Stream< T?> -
Creates an auto-updating stream of this statement, similar to
Selectable.watch. However, it is assumed that the query will only
emit one result, so instead of returning a
Stream<List<T>>
, this returns aStream<T?>
. If the query emits more than one row at some point, an error will be emitted to the stream instead. If the query emits zero rows at some point,null
will be added to the stream instead.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited