class Response { final T body; final int status; final bool operation; Response({this.body, this.operation, this.status}); factory Response.fromJson(Map data, Function parser) { return Response( body: parser(data['body']), status: data['status'], operation: data['operation']); } factory Response.fromJsonDynamic(Map data) { return Response( body: data['body'], status: data['status'], operation: data['operation']); } }