insertRow method

void insertRow(
  1. int index,
  2. List values, {
  3. bool isEditing = false,
})

Implementation

void insertRow(int index, List<dynamic> values, {bool isEditing = false}) {
  if (values.length != columns.length) {
    throw Exception('Values length must match columns');
  }
  if (isEditing && !showActions) {
    throw Exception(
        'Show actions must be true to make row editable either set isEditing false or set showActions to true');
  }
  if (index < 0 || index > data.length) {
    throw Exception('Index out of bounds');
  }

  data.insert(
      index,
      DynamicTableDataRow(
        index: index,
        isEditing: isEditing,
        cells: columns.map((e) {
          return DynamicTableDataCell(
            value: values[columns.indexOf(e)],
          );
        }).toList(),
      ));
  _editingValues[index] = values;
  _shiftValues(index, 1);
  if (isEditing) {
    _unsavedRows.add(index);
  }
  notifyListeners();
}