Selectable<T> class Null safety

Abstract class for queries which can return one-time values or a stream of values.

If you want to make your query consumable as either a Future or a Stream, you can refine your return type using one of Selectable's base classes:

/// Retrieve a page of [Todo]s.
MultiSelectable<Todo> pageOfTodos(int page, {int pageSize = 10}) {
  return select(todos)..limit(pageSize, offset: page);
}
pageOfTodos(1).get();
pageOfTodos(1).watch();
// Retrieve a todo known to exist.
SingleSelectable<Todo> entryById(int id) {
  return select(todos)..where((t) => t.id.equals(id));
}
final idGuaranteedToExist = 10;
entryById(idGuaranteedToExist).getSingle();
entryById(idGuaranteedToExist).watchSingle();
// 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();
Implemented types
Implementers

Constructors

Selectable()

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

get() Future<List<T>>
Executes this statement and returns the result.
override
getSingle() Future<T>
Executes this statement, like Selectable.get, but only returns one value. the query returns no or too many rows, the returned future will complete with an error. [...]
override
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. [...]
override
map<N>(N mapper(T)) Selectable<N>
Maps this selectable by the mapper function. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
A string representation of this object. [...]
inherited
watch() Stream<List<T>>
Creates an auto-updating stream of the result that emits new items whenever any table used in this statement changes.
override
watchSingle() 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 a Stream<T>. If, at any point, the query emits no or more than one rows, an error will be added to the stream instead. [...]
override
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 a Stream<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. [...]
override

Operators

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