TypeCasterRegistry class
A registry for custom type casters.
This class provides a way to register custom type casters for specific types,
which can then be used by the tryAs<T> and related functions.
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
-
clear(
) → void - Clears all registered custom casters.
-
getCustomCaster<
T> () → T Function(dynamic value, {T orElse()?})? - Gets the custom caster function for the specified type. Returns null if no custom caster is registered for the type.
-
hasCustomCaster<
T> () → bool - Checks if a custom caster is registered for the specified type.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
register<
T> (T casterFn(dynamic value, {T orElse()?})) → void - Registers a custom caster function for a specific type.
-
toString(
) → String -
A string representation of this object.
inherited
-
tryCustomCast<
T> (dynamic value, {T orElse()?}) → T? - Tries to cast the value using a registered custom caster. Returns null if no custom caster is registered for the type or if the cast fails.
-
unregister<
T> () → void - Unregisters a custom caster for the specified type.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → TypeCasterRegistry
-
Gets the singleton instance of the registry.
no setter