fromNative<T> method
T
fromNative<T>(
- dynamic value, {
- IterableKind kind = IterableKind.none,
- Type? type,
- TypeTree? tree,
Converts a value to its native representation using the converter
associated with T or type and the supplied IterableKind.
If tree is supplied, the converter associated with the tree is used.
Implementation
T fromNative<T>(dynamic value,
{IterableKind kind = IterableKind.none, Type? type, TypeTree? tree}) {
value = codec.preProcessNative(value);
// If the type is explicitly nullable, manually handle null values.
final isNullable = null is T;
if (value == null && isNullable) {
return null as T;
}
if (tree != null) {
final converter = getTreeConverter(tree);
return modeRegistry.nativeSerialization
.forConverter(converter, this)
.deserialize(value, this);
} else if (T == dynamic && type == null) {
final converter = findConverter(PolymorphicConverter)!;
return modeRegistry.nativeSerialization
.forConverter(converter, this)
.deserialize(value, this);
}
return convertIterableFromNative(value, type ?? T, kind);
}