buildDto<T> function
T
buildDto<T>(
- dynamic body
Implementation
T buildDto<T>(dynamic body) {
try {
/// reflection of the class
final dtoClassRef = reflectClass(T);
/// create new dto instance from generic type
final dtoReflection = dtoClassRef.newInstance(Symbol.empty, []);
final dto = initDto(dtoReflection.reflectee, body);
return dto as T;
} on BadRequest {
rethrow;
} catch (e) {
print(e);
throw BadRequest(data: ['body is not acceptable try to change the format']);
}
}