-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi_error.dart
More file actions
51 lines (44 loc) · 1.02 KB
/
api_error.dart
File metadata and controls
51 lines (44 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'package:piwigo_ng/utils/settings.dart';
enum ApiErrors {
error,
wrongLoginId,
wrongServerUrl,
fetchAlbumsError,
fetchAlbumListError,
fetchImagesError,
fetchFavoritesError,
searchImagesError,
getStatusError,
getInfoError,
getMethodsError,
createAlbumError,
deleteAlbumError,
editAlbumError,
moveAlbumError,
}
class PagingModel {
final int page;
final int nbPerPage;
final int nbTotal;
PagingModel({
this.page = 0,
this.nbPerPage = Settings.defaultElementPerPage,
this.nbTotal = 1,
});
PagingModel.fromJson({required Map<String, dynamic> json})
: page = json['page'] ?? 0,
nbPerPage = json['per_page'] ?? Settings.defaultElementPerPage,
nbTotal = json['count'] ?? 1;
}
class ApiResponse<T> {
final T? data;
final ApiErrors? error;
final PagingModel? paging;
const ApiResponse({
this.data,
this.error,
this.paging,
}) : assert(data != null || error != null);
bool get hasError => error != null;
bool get hasData => data != null;
}