class Warehouse { final int id; final String name; final String? location; final bool isDefault; const Warehouse({ required this.id, required this.name, this.location, required this.isDefault, }); factory Warehouse.fromJson(Map json) => Warehouse( id: (json['id'] as num).toInt(), name: json['name'] as String, location: json['location'] as String?, isDefault: json['is_default'] as bool? ?? false, ); Map toJson() => { 'name': name, if (location != null) 'location': location, 'is_default': isDefault, }; }