class FilamentModel { final String documentId; final String name; final String type; final String color; final double weight; final double weightUsed; final double price; final String manufacture; final String purchaseDate; final String? notes; final int printingTemp; final int bedTemp; FilamentModel({ required this.documentId, required this.name, required this.type, required this.color, required this.weight, required this.weightUsed, required this.price, required this.manufacture, required this.purchaseDate, this.notes, required this.printingTemp, required this.bedTemp, }); static FilamentModel fromJson(Map json) { return FilamentModel( documentId: json['\$id'], name: json['name'], type: json['type'], color: json['color'], weight: (json['weight'] as num).toDouble(), weightUsed: (json['weightUsed'] as num).toDouble(), price: (json['price'] as num).toDouble(), manufacture: json['manufacture'], purchaseDate: json['purchaseDate'], notes: json['notes'] as String?, printingTemp: json['printingTemp'], bedTemp: json['bedTemp'], ); } static Map toMapForAppwrite(FilamentModel filamentModel) { return { 'name': filamentModel.name, 'type': filamentModel.type, 'color': filamentModel.color, 'weight': filamentModel.weight, 'weightUsed': filamentModel.weightUsed, 'price': filamentModel.price, 'manufacture': filamentModel.manufacture, 'purchaseDate': filamentModel.purchaseDate, if (filamentModel.notes != null) 'notes': filamentModel.notes, 'printingTemp': filamentModel.printingTemp, 'bedTemp': filamentModel.bedTemp, }; } // An empty instance for initialization or default values static final empty = FilamentModel( documentId: '00', name: '', type: '', color: '', weight: 0.0, weightUsed: 0.0, price: 0.0, manufacture: '', purchaseDate: '', notes: null, printingTemp: 0, bedTemp: 0, ); }