dreampad/lib/app/models/base_response_model.dart

33 lines
721 B
Dart
Raw Permalink Normal View History

2023-11-28 10:44:58 +08:00
class BaseResponse {
bool? success;
int? code;
List<BaseErrors>? errors;
dynamic data;
BaseResponse({this.success, this.code, this.errors, this.data});
BaseResponse.fromJson(Map<String, dynamic> json) {
success = json['success'];
code = json['code'];
if (json.containsKey('errors')) {
errors = List<BaseErrors>.from(
json["errors"].map((x) => BaseErrors.fromJson(x)),
);
}
if (json.containsKey('data')) {
data = json['data'];
}
}
}
class BaseErrors {
int? code;
String? description;
BaseErrors({this.code, this.description});
BaseErrors.fromJson(Map<String, dynamic> json) {
code = json['code'];
description = json['description'];
}
}