fromMap causes Exception when used with generic type
Closed this issue · 2 comments
MohaAmiry commented
the following code throws an exception:
import 'package:dart_mappable/dart_mappable.dart';
part 'Test.mapper.dart';
@MappableClass()
class Response<T> with ResponseMappable<T> {
const Response();
static const fromMap = ResponseMapper.fromMap;
}
@MappableClass()
class Model with ModelMappable {
const Model();
}
// exception: MapperException: Failed to decode (Response<Model>): type 'Response<UnresolvedType>' is not a subtype of type 'Response<Model>' in type cast
Response<Model> modelResponse = Response.fromMap({});
how to cast Response<Model>
from a map using dart_mappable
?
schultek commented
Try calling ModelMapper.ensureInitialized()
beforehand.
MohaAmiry commented
problem solved, thank you :)..
i really appreciate the quick response, most of package maintainers take very long time to respond to issues.