base library

Base cloning implementation and interface for custom cloning strategies.

This library provides the foundational types for building cloning implementations:

Difference from core.dart:

  • core.dart exports the high-level Cloner API for everyday use
  • base.dart exports lower-level primitives for advanced customization

When to use base.dart:

  • Implementing a custom ICloning strategy (e.g., logging, metrics, special type handling)
  • Directly instantiating BaseCloner with specific options using builder pattern
  • Building frameworks or libraries that extend cloning behavior

Classes

AdaptiveCloner
Dispatches cloning operations to appropriate delegates based on configuration.
AdaptiveClonerBuilder
Builder for AdaptiveCloner, allowing configuration of delegates and mode.
BaseCloner
Performs element/value-wise cloning for built-in collections and delegates to ICloneable implementations for custom types.
BaseClonerBuilder
Builder for BaseCloner
CountedCloner
Extended with enforced recursion and size limits BaseCloner. The lightest way to prevent StackOverflow for circular references.
CountedClonerBuilder
Builder for CountedCloner
HashedCloner
Cloner with circular reference detection.
HashedClonerBuilder
Builder for HashedCloner
IClonerBuilding
Interface for types that can construct an ICloning instance (builder pattern).
ICloning
Interface for types that perform cloning operations (i.e., cloners).

Mixins

MClonerLogging
A mixin that adds logging capabilities to cloning operations.

Functions

deserializeBaseFlag(String data, {required String prefix}) bool
Deserializes the base flag and returns true if typed clone, false if dynamic.
serializeBaseFlag({required bool doTypedClone, String? prefix}) String
Serializes the base flag for clone type, optionally prefixed.