@@ -208,15 +208,16 @@ class AuthModel with ChangeNotifier {
208
208
final res = await http.get (Uri .parse ('${activeAccount !.domain }/api/v4$p ' ),
209
209
headers: {'Private-Token' : token});
210
210
final next = int .tryParse (
211
- res.headers['X-Next-Pages' ] ?? res.headers['x-next-page' ] ?? '' )! ;
211
+ res.headers['X-Next-Pages' ] ?? res.headers['x-next-page' ] ?? '' );
212
212
final info = json.decode (utf8.decode (res.bodyBytes));
213
213
if (info is Map && info['message' ] != null ) throw info['message' ];
214
214
return DataWithPage (
215
215
data: info,
216
- cursor: next,
216
+ cursor: next ?? 1 ,
217
217
hasMore: next != null ,
218
- total:
219
- int .tryParse (res.headers['X-Total' ] ?? res.headers['x-total' ] ?? '' )! ,
218
+ total: int .tryParse (
219
+ res.headers['X-Total' ] ?? res.headers['x-total' ] ?? '' ) ??
220
+ TOTAL_COUNT_FALLBACK ,
220
221
);
221
222
}
222
223
@@ -318,7 +319,8 @@ class AuthModel with ChangeNotifier {
318
319
data: info,
319
320
cursor: page + 1 ,
320
321
hasMore: info is List && info.length > 0 ,
321
- total: int .tryParse (res.headers['x-total-count' ] ?? '' )! ,
322
+ total: int .tryParse (res.headers['x-total-count' ] ?? '' ) ??
323
+ TOTAL_COUNT_FALLBACK ,
322
324
);
323
325
}
324
326
@@ -421,7 +423,8 @@ class AuthModel with ChangeNotifier {
421
423
data: info,
422
424
cursor: page + 1 ,
423
425
hasMore: info is List && info.length > 0 ,
424
- total: int .tryParse (res.headers['x-total-count' ] ?? '' )! ,
426
+ total: int .tryParse (res.headers['x-total-count' ] ?? '' ) ??
427
+ TOTAL_COUNT_FALLBACK ,
425
428
);
426
429
}
427
430
@@ -504,7 +507,8 @@ class AuthModel with ChangeNotifier {
504
507
final info = json.decode (utf8.decode (res.bodyBytes));
505
508
506
509
final totalPage = int .tryParse (res.headers['total_page' ] ?? '' );
507
- final totalCount = int .tryParse (res.headers['total_count' ] ?? '' )! ;
510
+ final totalCount =
511
+ int .tryParse (res.headers['total_count' ] ?? '' ) ?? TOTAL_COUNT_FALLBACK ;
508
512
509
513
return DataWithPage (
510
514
data: info,
@@ -584,7 +588,7 @@ class AuthModel with ChangeNotifier {
584
588
final v = BbPagination .fromJson (data);
585
589
return BbPagePayload (
586
590
cursor: v.next,
587
- total: v.size! ,
591
+ total: v.size ?? TOTAL_COUNT_FALLBACK ,
588
592
data: v.values,
589
593
hasMore: v.next != null ,
590
594
);
0 commit comments