getError method

String? getError(
  1. dynamic data,
  2. String column, [
  3. String? cellKey
])

Resolves the error message for a specific cell, if any.

Implementation

String? getError(dynamic data, String column, [String? cellKey]) {
  // 1. Check errors notifier if provided
  if (errorsNotifier != null) {
    final map = errorsNotifier!.value;
    if (cellKey != null && map.containsKey(cellKey)) {
      return map[cellKey];
    }
    if (map.containsKey(column)) {
      return map[column];
    }
  }
  // 2. Check static cell errors map
  if (cellErrors != null) {
    if (cellKey != null && cellErrors!.containsKey(cellKey)) {
      return cellErrors![cellKey];
    }
    if (cellErrors!.containsKey(column)) {
      return cellErrors![column];
    }
  }
  // 3. Check cellErrorBuilder callback
  if (cellErrorBuilder != null && data != null) {
    return cellErrorBuilder!(data, column);
  }
  return null;
}