Add FilamentModel with all properties and refactor notes as optional

This commit is contained in:
2026-03-03 09:11:38 +01:00
commit 18c156c9d1
62 changed files with 192467 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
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<String, dynamic> 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<String, dynamic> 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,
);
}