You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.6 KiB
75 lines
1.6 KiB
class Product {
|
|
final int? id;
|
|
final String name;
|
|
final double price;
|
|
final String? image;
|
|
final String category;
|
|
final int stock;
|
|
final String? description;
|
|
String? qrCode;
|
|
final String? reference;
|
|
final int? pointDeVenteId;
|
|
final String? marque;
|
|
final String? ram;
|
|
final String? memoireInterne;
|
|
final String? imei;
|
|
|
|
Product({
|
|
this.id,
|
|
required this.name,
|
|
required this.price,
|
|
this.image,
|
|
required this.category,
|
|
this.stock = 0,
|
|
this.description,
|
|
this.qrCode,
|
|
this.reference,
|
|
this.pointDeVenteId,
|
|
this.marque,
|
|
this.ram,
|
|
this.memoireInterne,
|
|
this.imei,
|
|
|
|
});
|
|
bool isStockDefined() {
|
|
if (stock != null) {
|
|
print("stock is defined : $stock $name");
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
factory Product.fromMap(Map<String, dynamic> map) => Product(
|
|
id: map['id'],
|
|
name: map['name'],
|
|
price: map['price'],
|
|
image: map['image'],
|
|
category: map['category'],
|
|
stock: map['stock'],
|
|
description: map['description'],
|
|
qrCode: map['qrCode'],
|
|
reference: map['reference'],
|
|
pointDeVenteId: map['point_de_vente_id'],
|
|
marque: map['marque'],
|
|
ram: map['ram'],
|
|
memoireInterne: map['memoire_interne'],
|
|
imei: map['imei'],
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
'id': id,
|
|
'name': name,
|
|
'price': price,
|
|
'image': image,
|
|
'category': category,
|
|
'stock': stock,
|
|
'description': description,
|
|
'qrCode': qrCode,
|
|
'reference': reference,
|
|
'point_de_vente_id': pointDeVenteId,
|
|
'marque': marque,
|
|
'ram': ram,
|
|
'memoire_interne': memoireInterne,
|
|
'imei': imei,
|
|
};
|
|
}
|