query<T> method
Executes a SQLite query that may return a single value.
Implementation
Future<T?> query<T>(
final String sql, {
final List<Object>? arguments,
required final T Function(Map<String, Object?>) mapper,
}) async {
final rows = await _preformQuery(sql, arguments);
if (rows.isEmpty) {
return null;
} else if (rows.length > 1) {
throw StateError("Query returned more than one row for '$sql'");
}
return mapper(rows.first);
}