You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
492 B
Dart
23 lines
492 B
Dart
|
3 years ago
|
class Part{
|
||
|
|
String id;
|
||
|
|
String code;
|
||
|
|
String name;
|
||
|
|
int quantity;
|
||
|
|
|
||
|
|
Part({
|
||
|
|
this.id,
|
||
|
|
this.code,
|
||
|
|
this.name,
|
||
|
|
this.quantity = 1,
|
||
|
|
});
|
||
|
|
|
||
|
|
factory Part.fromJson(Map<String,dynamic> parsedJson){
|
||
|
|
return Part(
|
||
|
|
id: parsedJson["nid"] ?? parsedJson["id"],
|
||
|
|
code: parsedJson["part_code"] ?? parsedJson["name"],
|
||
|
|
name: parsedJson["part_name"],
|
||
|
|
quantity: parsedJson["qty"] == null
|
||
|
|
? 1 : int.tryParse(parsedJson["qty"].toString()) ?? 1,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|