onRowEdit property
Called when the user clicks on the edit icon of a row.
Return true to allow the edit action, false to prevent it. If the action is allowed, the row will be editable.
bool onRowEdit(int index, List<dynamic> row){
//Do some validation on row and return false if validation fails
if (index%2==1) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Cannot edit odd rows"),
),
);
return false; // The row will not open in editable mode
}
return true; // The row will open in editable mode
}
Implementation
final bool Function(int index, List<dynamic> row)? onRowEdit;