core library
Core cloning API and contracts for the Cloner library.
This library provides the primary entry point for cloning operations:
- Cloner: Static API with convenience methods and global reference management
- ICloneable: Interface for types that support deep cloning
- ICopyable: Interface for types that support shallow copying
- UnsupportedTypedCloneException: Thrown when typed cloning fails
- CircularReferenceCloneException: Thrown when circular references are detected
- LimitExceededException: Thrown when a cloning operation exceeds a predefined resource or recursion limit
Difference from base.dart:
core.dartexports the high-level Cloner API for most use casesbase.dartexports BaseCloner and ICloning for custom implementations
For most applications, import this library:
import 'package:cloner/core.dart';
final cloned = Cloner.instance().cloneValue(original);
To customize cloning behavior, see base.dart for implementing ICloning.
Classes
- Cloner
- Provides access to the global cloning implementation.
-
ICloneable<
T extends Object> -
Contracts used by
Clonerand collection helpers. -
ICopyable<
T extends Object> - Use for a shallow, element-wise copy.
- IRestorable
- Provides a contract for objects that can be restored to their initial state.
-
ISerializable<
O, D> -
Contract for serializing an object
Oto dataD.
Typedefs
-
ISerializableAsync<
O, D> = ISerializable< O, Future< D> > -
Asynchronous variant of ISerializable where serialization returns a
Future.
Exceptions / Errors
- ACloneException
- Base exception for errors encountered during cloning operations.
- ASerializationException
- Base class for serialization-related exceptions.
- CircularReferenceCloneException
- Thrown when a circular reference is detected during cloning.
- DeserializationException
- Exception thrown on deserialization failure.
- DeserializationFormatException
- Exception thrown when the format of the data is invalid during deserialization.
- DeserializationTypeException
- Exception thrown when a deserialized value is of an unexpected type.
- LimitExceededException
- Thrown when some limit is exceeded.
- SerializationException
- Exception thrown on serialization failure.
- UnsupportedTypedCloneException
- Thrown when typed cloning encounters an unsupported nested structure.