fix phone dashboard
This commit is contained in:
@@ -58,12 +58,27 @@ class CustomerListResponse {
|
||||
required this.pageSize,
|
||||
});
|
||||
|
||||
factory CustomerListResponse.fromApi(dynamic json) {
|
||||
if (json is List<dynamic>) {
|
||||
final customers = json
|
||||
.map((e) => Customer.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
return CustomerListResponse(
|
||||
data: customers,
|
||||
total: customers.length,
|
||||
page: 1,
|
||||
pageSize: customers.length,
|
||||
);
|
||||
}
|
||||
return CustomerListResponse.fromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
factory CustomerListResponse.fromJson(Map<String, dynamic> json) =>
|
||||
CustomerListResponse(
|
||||
data: (json['data'] as List<dynamic>)
|
||||
data: ((json['data'] ?? const <dynamic>[]) as List<dynamic>)
|
||||
.map((e) => Customer.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
total: json['total'] as int? ?? 0,
|
||||
total: json['total'] as int? ?? ((json['data'] as List<dynamic>?)?.length ?? 0),
|
||||
page: json['page'] as int? ?? 1,
|
||||
pageSize: json['pageSize'] as int? ?? 20,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user