class TankGuruDirectusModel { int? iD; String? userIdentId; String? tankDate; String? odometer; String? liter; String? pricePerLiter; String? standort; String? createdAt; String? szPriceTotal; TankGuruDirectusModel( {this.iD, this.userIdentId, this.tankDate, this.odometer, this.liter, this.pricePerLiter, this.standort, this.createdAt, this.szPriceTotal}); TankGuruDirectusModel.fromJson(Map json) { iD = json['ID']; userIdentId = json['UserIdentId']; tankDate = json['TankDate']; odometer = json['Odometer']; liter = json['Liter']; pricePerLiter = json['PricePerLiter']; standort = json['Standort']; createdAt = json['CreatedAt']; // Berechnung des Gesamtpreises if (liter != null && pricePerLiter != null) { double literValue = double.tryParse(liter!) ?? 0.0; double pricePerLiterValue = double.tryParse(pricePerLiter!) ?? 0.0; szPriceTotal = (literValue * pricePerLiterValue).toStringAsFixed(2); } else { szPriceTotal = '0.00'; } } Map toJson() { final Map data = {}; data['ID'] = iD; data['UserIdentId'] = userIdentId; data['TankDate'] = tankDate; data['Odometer'] = odometer; data['Liter'] = liter; data['PricePerLiter'] = pricePerLiter; data['Standort'] = standort; data['CreatedAt'] = createdAt; data['SzPriceTotal'] = szPriceTotal; return data; } }