backup. before shop update
This commit is contained in:
66
lib/models/Subproduct.dart
Normal file
66
lib/models/Subproduct.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_wisetronic/models/product_attribute.dart';
|
||||
|
||||
class Subproduct {
|
||||
int id;
|
||||
SimpleProduct product;
|
||||
double quantity;
|
||||
|
||||
Subproduct.fromJson(Map<String, dynamic> json) :
|
||||
id = json['id'],
|
||||
product = SimpleProduct.fromJson(json['product']),
|
||||
quantity = double.parse(json['quantity'].toString());
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'product': product,
|
||||
'quantity': quantity,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleProduct {
|
||||
int id;
|
||||
String name;
|
||||
String sku;
|
||||
double price;
|
||||
String description;
|
||||
String image;
|
||||
List<ProductAttribute> productAttributes;
|
||||
double customerLastPrice;
|
||||
String extraData;
|
||||
|
||||
SimpleProduct.fromJson(Map<String, dynamic> json) :
|
||||
id = json['id'],
|
||||
name = json['name'],
|
||||
sku = json['sku'],
|
||||
price = double.parse(json['price'].toString()),
|
||||
description = json['description'],
|
||||
image = json['image'],
|
||||
productAttributes = (json['productattributes'] as List).map((i) => ProductAttribute.fromJson(i)).toList(),
|
||||
customerLastPrice = double.parse(json['customer_last_price'].toString()),
|
||||
extraData = json['extra_data'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'sku': sku,
|
||||
'price': price,
|
||||
'description': description,
|
||||
'image': image,
|
||||
'productattributes': productAttributes,
|
||||
'customer_last_price': customerLastPrice,
|
||||
'extra_data': extraData,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user