If I have a class such as MyClass<MySubtype> and an instance that has been deserialized into MyClass<dynamic>, how can I manually cast/convert it back into MyClass<MySubtype>?
I don't necessarily need to always do this as part of the deserialization, just occasionally on demand under specific circumstances.
I tried using copyWith like so: myInstance.copyWith<MyClass<MySubtype>>(); but copyWith doesn't appear to accept a type parameter in version 2.0.0-dev.11. I think I saw this functionality in an earlier version but am not 100% sure.
I also tried to use a container: myMapperContainer.fromValue<MyClass<MySubtype>>(myInstance); but mappable wants the instance to be a primitive such as a map. This makes sense but I don't want to serialize / deserialize just to change the subtype.
I'm probably missing something obvious here but even so, it might be helpful to document this somewhere.
If I have a class such as
MyClass<MySubtype>
and an instance that has been deserialized intoMyClass<dynamic>
, how can I manually cast/convert it back intoMyClass<MySubtype>
?I don't necessarily need to always do this as part of the deserialization, just occasionally on demand under specific circumstances.
I tried using
copyWith
like so:myInstance.copyWith<MyClass<MySubtype>>();
but copyWith doesn't appear to accept a type parameter in version 2.0.0-dev.11. I think I saw this functionality in an earlier version but am not 100% sure.I also tried to use a container:
myMapperContainer.fromValue<MyClass<MySubtype>>(myInstance);
but mappable wants the instance to be a primitive such as a map. This makes sense but I don't want to serialize / deserialize just to change the subtype.I'm probably missing something obvious here but even so, it might be helpful to document this somewhere.