deleteProperty static method

bool deleteProperty(
  1. dynamic val,
  2. dynamic prop
)

Implementation

static bool deleteProperty(dynamic val, dynamic prop) {
  if (val == null) {
    return false;
  } else if (val is Invokable) {
    // For Invokable objects, try to use deleteProperty if available
    try {
      val.setProperty(prop, null);
      return true;
    } catch (e) {
      return false;
    }
  } else if (val is Map) {
    return val.remove(prop) != null;
  } else if (val is List) {
    // For lists, delete by index
    if (prop is int && prop >= 0 && prop < val.length) {
      val.removeAt(prop);
      return true;
    }
    return false;
  }
  // For other types, deletion is not supported
  return false;
}