cloneSync method

T cloneSync()

Implementation

T cloneSync() {
  if (this == null) return this;

  if (this is num || this is String || this is bool) {
    return this;
  }

  if (this is List) {
    return List.from(this as List) as T;
  }

  if (this is Map) {
    return Map.from(this as Map) as T;
  }

  if (this is Set) {
    return Set.from(this as Set) as T;
  }

  throw const CloneException('cloneSync() only supports primitives, lists, maps, and sets. Use clone() for complex objects.');
}