Amélioration page ship

This commit is contained in:
Gabriel
2023-05-31 16:59:34 +02:00
parent f492aad527
commit bc9ffeda59
4 changed files with 229 additions and 103 deletions

View File

@@ -58,15 +58,22 @@ class Inventory {
class Cargo {
int? capacity;
int? units;
//List<Inventory>? inventory;
List<Inventory>? inventory;
Cargo({this.capacity, this.units});//, this.inventory});
Cargo({this.capacity, this.units, this.inventory});
factory Cargo.fromJson(Map<String, dynamic> json) {
var inventoryList = json['inventory'] as List<dynamic>?;
List<Inventory>? parsedInventoryList;
if (inventoryList != null) {
parsedInventoryList = inventoryList
.map((item) => Inventory.fromJson(item))
.toList();
}
return Cargo(
capacity: json['capacity'],
units: json['units'],
//inventory: json.decode(json['inventory']),
inventory: parsedInventoryList,
);
}
}