import 'dart:convert'; import '../ads/Images.dart'; import '../services/images.dart'; /// id : 153944 /// quantity : 3 /// serviceduration : 30.0 /// description : "Testing services 1" /// price : 20.2 /// name : "test test" /// ratingAverage : 5 /// images : [{"url":"/WebContent/product/1683714876805testtest0svg","type":"image/svg+xml"},{"url":"/WebContent/product/1683714876808testtest1svg","type":"image/svg+xml"}] ServiceOrder serviceOrderFromJson(String str) => ServiceOrder.fromJson(json.decode(str)); String serviceOrderToJson(ServiceOrder data) => json.encode(data.toJson()); class ServiceOrder { ServiceOrder({ this.id, this.quantity, this.serviceduration, this.description, this.price, this.name, this.ratingAverage, this.archive, this.nomAr, this.sold, this.soldStartDate, this.soldEndDate, this.promoCode, this.timestmp, this.images, }); factory ServiceOrder.fromJson(Map json) => ServiceOrder( id: json['id'] as int?, quantity: json['quantity'] ?? 0, serviceduration: (json['serviceduration'] as num?)?.toDouble() ?? 0.0, description: json['description'] as String? ?? '', price: (json['price'] as num?)?.toDouble() ?? 0.0, name: json['name'] as String? ?? '', ratingAverage: (json['ratingAverage'] as num?)?.toDouble() ?? 0.0, archive: json['archive'] as bool? ?? false, nomAr: json['nomAr'] as String? ?? '', sold: json['sold'] as String?, soldStartDate: json['soldStartDate'] as int?, soldEndDate: json['soldEndDate'] as int?, promoCode: json['promoCode'] as String?, timestmp: json['timestmp'] as int?, images: (json['images'] as List?) ?.map((e) => Images.fromJson(e as Map)) .toList() ?? [], ); int? id; int? quantity; double? serviceduration; String? description; double? price; String? name; double? ratingAverage; List? images; String? nomAr; bool? archive; String? sold; int? soldStartDate; int? soldEndDate; String? promoCode; int? timestmp; Map toJson() { final map = {}; map['id'] = id; map['quantity'] = quantity; map['serviceduration'] = serviceduration; map['description'] = description; map['price'] = price; map['name'] = name; map['ratingAverage'] = ratingAverage; if (images != null) { map['images'] = images?.map((v) => v.toJson()).toList(); } return map; } }