QueryResult.fromRows constructor

  1. List<Map<String, dynamic>> rows

Converts the rows into columnNames and raw data QueryResult.rows. We assume that each map in rows has the same keys.


factory QueryResult.fromRows(List<Map<String, dynamic>> rows) {
  if (rows.isEmpty) {
    return QueryResult(const [], const []);

  final keys = rows.first.keys.toList();
  final mappedRows = [
    for (var row in rows) [for (var key in keys) row[key]]

  return QueryResult(keys, mappedRows);