insertRow method
Implementation
Future<bool> insertRow(String? jsonOrXml, int? rowIndex) async {
try {
var view = findListenerOfExactType(TableViewState);
if (view is TableViewState) {
// get current row index if not specified
rowIndex ??= view.currentRowIndex ?? 0;
// add empty element to the data set
// important to do this first as
// get row model below depends on an entry
// in the dataset at specified index
notificationsEnabled = false;
myDataSource?.insert(jsonOrXml, rowIndex, notifyListeners: false);
data = myDataSource?.data ?? data;
notificationsEnabled = true;
// open up a space for the new model
insertInHashmap(rows, rowIndex);
// create new row
var row = getRowModel(rowIndex);
// add row to rows
if (row != null) {
rows[rowIndex] = row;
// fire the rows onInsert event
await row.onInsertHandler();
}
//data = myDataSource?.notify();
// add row to table view
rowIndex = view.insertRow(rowIndex);
}
} catch (e) {
Log().exception(e);
}
return true;
}