Files
flutter_wisetronic/lib/models/simple_product.dart
2021-08-31 13:28:33 -04:00

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);
}
}