CollectionToCollectionConverter class abstract
An abstract base class for converting between different types of Dart collections, with optional element type conversion.
This converter works by:
- Checking if the source type matches the expected
this. - Verifying that the target type is a supported collection type.
- Converting each element if type information is available.
Supported target types include:
List,Set,Iterable,QueueArrayList,HashSet,LinkedQueue,LinkedList,LinkedStack,Stackcol.LinkedHashSet,col.ListBase,col.SetBase,col.Queue
Example:
final service = ConversionService(); // Your implementation
final converter = ListToCollectionConverter(service);
final source = [1, 2, 3];
final result = converter.convert(
source,
Class.forType(List),
Class.forType(Set),
);
print(result.runtimeType); // Set<int>
Subclasses specify the exact source type (e.g., List, Set) via _sourceDartType.
- Inheritance
-
- Object
- PairedConverter
- PairedConditionalConverter
- CollectionToCollectionConverter
- Implementers
- ArrayListToCollectionGenericConverter
- HashSetToCollectionGenericConverter
- IterableToCollectionGenericConverter
- LinkedHashSetToCollectionGenericConverter
- LinkedListToCollectionGenericConverter
- LinkedQueueToCollectionGenericConverter
- LinkedStackToCollectionGenericConverter
- ListBaseToCollectionConverter
- ListToCollectionConverter
- QueueToCollectionGenericConverter
- SetBaseToCollectionGenericConverter
- SetToCollectionGenericConverter
- StackToCollectionGenericConverter
Constructors
- CollectionToCollectionConverter(ConversionService _conversionService, Class _source)
- An abstract base class for converting between different types of Dart collections, with optional element type conversion.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
convert<
T> (Object? source, Class sourceType, Class targetType) → Object? -
A general-purpose converter that can convert between multiple source–target type pairs.
override
-
getConvertibleTypes(
) → Set< ConvertiblePair> ? -
A general-purpose converter that can convert between multiple source–target type pairs.
override
-
getPackageName(
) → String -
Represents an abstraction for identifying the package that an object,
resource, or service belongs to.
inherited
-
matches(
Class sourceType, Class targetType) → bool -
A contract for a converter that only matches under certain conditions.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited