SqlIterator class

A row iterator obtained from SqlClient.

An example:

import 'package:database/database.dart';

Future<void> example(SqlClient sqlClient) async {
  final iterator = await sqlClient.query('SELECT * FROM Product').getIterator();

  // While we have more rows
  while (await iterator.next()) {
    // Read the current row
    final map = iterator.rowAsMap();
  }
}

Constructors

SqlIterator.constructor()
SqlIterator.fromFunction({@required List<SqlColumnDescription> columnDescriptions, @required Future<List<List>> onNextRowBatch({int length})})
Constructs a database iterator from column descriptions and a batch-returning function.
factory
SqlIterator.fromLists({@required List<SqlColumnDescription> columnDescriptions, @required List<List> rows})
factory
SqlIterator.fromMaps(Iterable<Map<String, Object>> maps, {List<SqlColumnDescription> columnDescriptions})
Constructs a database iterator from in-memory Iterable.
factory

Properties

columnDescriptions List<SqlColumnDescription>
Descriptions of columns. Must be non-null and the length must be equal to the length of every rows.
read-only
currentRow List
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
isClosed bool
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

asMap() Map<String, Object>
Reads the next row as a map. If there are no more rows, returns null.
close() Future<void>
index(int index) Object
Returns current value in the column with the specified index. [...]
next() Future<bool>
Reads the next row as list. If there are no more rows, returns null.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
property(String name, {String tableName}) Object
Returns current value in the column with the specified name. [...]
readBatchOfMaps({int length}) Future<List<Map<String, Object>>>
Reads the next batch of rows as a map. If there are no more rows, returns null. This method could have better performance than reading row-by-row. [...]
readBatchOfRows({int length}) Future<List<List>>
Reads the next batch of rows as a list. If there are no more rows, returns null. This method could have better performance than reading row-by-row. [...]
readMapStream() Stream<Map<String, Object>>
Reads all remaining rows as a stream of maps. Each row is immutable.
readRowStream() Stream<List>
Reads all remaining rows as a stream of lists. Each row is immutable.
toMaps() Future<List<Map<String, Object>>>
Reads all remaining rows as maps. The result is immutable.
toRows() Future<List<List>>
Reads all remaining rows as lists. The result is immutable.
toString() String
Returns a string representation of this object.
inherited

Operators

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