fix phone dashboard

This commit is contained in:
root
2026-05-27 03:11:45 -04:00
parent 7ca43ba2f3
commit 1112b04516
48 changed files with 1222 additions and 368 deletions
+17 -2
View File
@@ -72,12 +72,27 @@ class VehicleListResponse {
required this.pageSize,
});
factory VehicleListResponse.fromApi(dynamic json) {
if (json is List<dynamic>) {
final vehicles = json
.map((e) => Vehicle.fromJson(e as Map<String, dynamic>))
.toList();
return VehicleListResponse(
data: vehicles,
total: vehicles.length,
page: 1,
pageSize: vehicles.length,
);
}
return VehicleListResponse.fromJson(json as Map<String, dynamic>);
}
factory VehicleListResponse.fromJson(Map<String, dynamic> json) =>
VehicleListResponse(
data: (json['data'] as List<dynamic>)
data: ((json['data'] ?? const <dynamic>[]) as List<dynamic>)
.map((e) => Vehicle.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,
);