Skip to content

Instantly share code, notes, and snippets.

@JaveedIshaq
Created April 17, 2020 06:21
Show Gist options
  • Save JaveedIshaq/c2d1a66e98b251fa06a44d21e6989713 to your computer and use it in GitHub Desktop.
Save JaveedIshaq/c2d1a66e98b251fa06a44d21e6989713 to your computer and use it in GitHub Desktop.
model class
class RequestRateModel {
List<Packages> packages;
double weight;
Addresses addresses;
RequestRateModel({this.packages, this.weight, this.addresses});
RequestRateModel.fromJson(Map<String, dynamic> json) {
if (json['packages'] != null) {
packages = new List<Packages>();
json['packages'].forEach((v) {
packages.add(new Packages.fromJson(v));
});
}
weight = json['weight'];
addresses = json['addresses'] != null
? new Addresses.fromJson(json['addresses'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.packages != null) {
data['packages'] = this.packages.map((v) => v.toJson()).toList();
}
data['weight'] = this.weight;
if (this.addresses != null) {
data['addresses'] = this.addresses.toJson();
}
return data;
}
}
class Packages {
double weight;
double height;
double width;
double length;
int quantity;
int type;
Packages(
{this.weight,
this.height,
this.width,
this.length,
this.quantity,
this.type});
Packages.fromJson(Map<String, dynamic> json) {
weight = json['weight'];
height = json['height'];
width = json['width'];
length = json['length'];
quantity = json['quantity'];
type = json['type'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['weight'] = this.weight;
data['height'] = this.height;
data['width'] = this.width;
data['length'] = this.length;
data['quantity'] = this.quantity;
data['type'] = this.type;
return data;
}
}
class Addresses {
int origin;
int destination;
Addresses({this.origin, this.destination});
Addresses.fromJson(Map<String, dynamic> json) {
origin = json['origin'];
destination = json['destination'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['origin'] = this.origin;
data['destination'] = this.destination;
return data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment