buildMapperImplementation function
Method
buildMapperImplementation()
Generates the implemented mapper method by the given abstract MethodElement.
Implementation
Method buildMapperImplementation(Map<String, dynamic> config,
MethodElement method, ClassElement abstractMapper) {
if (method.returnType.element2 == null) {
throw InvalidGenerationSourceError(
'${method.returnType} is not a valid return type',
element: method,
todo: 'Add valid return type to mapping method');
}
return Method((b) => b
..annotations.add(CodeExpression(Code('override')))
..name = method.displayName
..requiredParameters.addAll(method.parameters.map((e) => copyParameter(e)))
..body = _generateBody(config, method, abstractMapper)
..returns =
refer(method.returnType.getDisplayString(withNullability: true)));
}