addRow method
Adds a row of data to the bulk insert.
The values list must contain values in the same order as columns
were added, and must match the column count.
The builder stores the row list reference directly for performance.
Do not modify values after passing it to this method.
Returns this builder for method chaining. Throws StateError if columns haven't been added yet. Throws ArgumentError if the row length doesn't match column count.
Implementation
BulkInsertBuilder addRow(List<dynamic> values) {
if (_columns.isEmpty) {
throw StateError('Add columns before rows');
}
if (values.length != _columns.length) {
throw ArgumentError(
'Row length ${values.length} != column count ${_columns.length}',
);
}
final rowNumber = _rows.length + 1;
for (var c = 0; c < _columns.length; c++) {
_validateValueForColumn(values[c], _columns[c], rowNumber);
}
_rows.add(values);
return this;
}