deleteRow method

Future<bool> deleteRow(
  1. int? rowIndex
)

Implementation

Future<bool> deleteRow(int? rowIndex) async {
  try {
    var view = findListenerOfExactType(TableViewState);
    if (view is TableViewState) {
      // delete row from table view
      rowIndex = view.deleteRow(rowIndex);

      // row was deleted?
      if (rowIndex != null) {
        // lookup the row
        var row = rows.containsKey(rowIndex) ? rows[rowIndex] : null;
        if (row != null) {
          // fire the rows onDelete event
          bool ok = await row.onDeleteHandler();

          // continue?
          if (ok) {
            // reorder hashmap
            deleteInHashmap(rows, rowIndex);

            // remove the data associated with the row
            notificationsEnabled = false;
            myDataSource?.delete(rowIndex, notifyListeners: false);
            data = myDataSource?.data ?? data;
            notificationsEnabled = true;
          }
        }
      }
    }
  } catch (e) {
    Log().exception(e);
  }
  return true;
}