feat:dio client done
This commit is contained in:
20
lib/feature/common/data/models/error_model.dart
Normal file
20
lib/feature/common/data/models/error_model.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import '../../domain/entities/error_entity.dart';
|
||||
|
||||
class ErrorModel extends ErrorEntity {
|
||||
const ErrorModel({super.detail});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {"detail": detail};
|
||||
}
|
||||
|
||||
factory ErrorModel.fromJson(Map<String, dynamic> data) {
|
||||
if (data.containsKey("detail")) {
|
||||
if (data['detail'] is List) {
|
||||
return ErrorModel(detail: data['detail'][0]["msg"]);
|
||||
} else {
|
||||
return ErrorModel(detail: data['detail']);
|
||||
}
|
||||
}
|
||||
return ErrorModel(detail: data['message']);
|
||||
}
|
||||
}
|
||||
5
lib/feature/common/domain/entities/error_entity.dart
Normal file
5
lib/feature/common/domain/entities/error_entity.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
class ErrorEntity {
|
||||
final String detail;
|
||||
|
||||
const ErrorEntity({this.detail = ''});
|
||||
}
|
||||
Reference in New Issue
Block a user