32 lines
717 B
Dart
32 lines
717 B
Dart
import 'dart:convert';
|
|
|
|
class SimpleProduct {
|
|
int id;
|
|
String name;
|
|
double price;
|
|
double regularPrice;
|
|
String description;
|
|
String imagePath;
|
|
|
|
SimpleProduct.fromJson(Map<String, dynamic> json)
|
|
: id = json['id'],
|
|
name = json['name'],
|
|
price = double.parse(json['price'].toString()),
|
|
regularPrice = double.parse(json['regular_price'].toString()),
|
|
description = json['description'],
|
|
imagePath = json['image_path'];
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'name': name,
|
|
'price': price,
|
|
'regular_price': regularPrice,
|
|
'description': description,
|
|
'image_path': imagePath
|
|
};
|
|
|
|
@override
|
|
String toString() {
|
|
return json.encode(this);
|
|
}
|
|
} |