core library

Core cloning API and contracts for the Cloner library.

This library provides the primary entry point for cloning operations:

Difference from base.dart:

  • core.dart exports the high-level Cloner API for most use cases
  • base.dart exports BaseCloner and ICloning for custom implementations

For most applications, import this library:

import 'package:cloner/core.dart';

final cloned = Cloner.instance().cloneValue(original, doTypedClone: true);

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 Cloner and 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 O to data D.

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.