oneOrNull method
Returns the only row produced by this operation, or null for no rows.
Throws StateError when multiple rows are returned. Projection reads built by SqlQueries.select fetch at most two rows for this check. An explicit query limit of zero, one, or two is preserved.
If R is nullable, null cannot distinguish no row from one row whose
projection decodes to null; use one or all when that distinction
matters.
Implementation
Future<R?> oneOrNull(SqlExecutor executor) async {
final rows = await _cardinalityRows(executor);
if (rows.length > 1) {
throw StateError(
'Expected at most one SQL row, but multiple rows were returned.',
);
}
return rows.isEmpty ? null : _decode(rows.single);
}