import 'dart:convert'; class SupplierResponse { List data; SupplierResponse({required this.data}); factory SupplierResponse.fromJson(Map json) => SupplierResponse( data: List.from(json["data"].map((x) => Supplier.fromJson(x))), ); Map toJson() => { "data": List.from(data.map((x) => x.toJson())), }; } class Supplier { String namaSupplier; int jumlahKesesuaianBahan; List produk; Supplier({ required this.namaSupplier, required this.jumlahKesesuaianBahan, required this.produk, }); factory Supplier.fromJson(Map json) => Supplier( namaSupplier: json["nama_supplier"], jumlahKesesuaianBahan: json["jumlah_kesesuaian_bahan"], produk: List.from(json["produk"].map((x) => Produk.fromJson(x))), ); Map toJson() => { "nama_supplier": namaSupplier, "jumlah_kesesuaian_bahan": jumlahKesesuaianBahan, "produk": List.from(produk.map((x) => x.toJson())), }; } class Produk { String namaBahan; double harga; String satuan; String alamat; int berat; int idProduct; String namaSupplier; Produk({ required this.namaBahan, required this.harga, required this.satuan, required this.alamat, required this.berat, required this.idProduct, required this.namaSupplier, }); factory Produk.fromJson(Map json) => Produk( namaBahan: json["nama_bahan"], harga: json["harga"], satuan: json["satuan"], alamat: json["alamat"], berat: json["berat"], idProduct: json["id_product"], namaSupplier: json["nama_supplier"], ); Map toJson() => { "nama_bahan": namaBahan, "harga": harga, "satuan": satuan, "alamat": alamat, "berat": berat, "id_product": idProduct, "nama_supplier": namaSupplier, }; }