add structure
This commit is contained in:
236
lib/vo/manual.dart
Normal file
236
lib/vo/manual.dart
Normal file
@@ -0,0 +1,236 @@
|
||||
class ManualItem {
|
||||
int id;
|
||||
dynamic title;
|
||||
dynamic titlemm;
|
||||
List<SlideData> slides;
|
||||
bool isBuyer;
|
||||
ManualItem({this.id, this.title, this.titlemm, this.slides, this.isBuyer});
|
||||
|
||||
factory ManualItem.fromJson(Map<String, dynamic> json) {
|
||||
var list = json['slides'] as List;
|
||||
List<SlideData> slideList = list.map((i) => SlideData.fromJson(i)).toList();
|
||||
return ManualItem(
|
||||
id: json['id'],
|
||||
title: json['title'],
|
||||
titlemm: json['titlemm'],
|
||||
isBuyer: json['isBuyer'],
|
||||
slides: slideList);
|
||||
}
|
||||
|
||||
factory ManualItem.fromMap(Map<String, dynamic> map) {
|
||||
var list = map['slides'] as List;
|
||||
List<SlideData> slideList = list.map((i) => SlideData.fromJson(i)).toList();
|
||||
return ManualItem(
|
||||
id: map['id'],
|
||||
title: map['title'],
|
||||
titlemm: map['titlemm'],
|
||||
isBuyer: map['isBuyer'],
|
||||
slides: slideList);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'title': "$title",
|
||||
'titlemm': "$titlemm",
|
||||
'isBuyer': isBuyer,
|
||||
'slides': slides.map((slide) {
|
||||
return slide.toJson();
|
||||
}).toList(),
|
||||
};
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'titlemm': titlemm,
|
||||
'isBuyer': isBuyer,
|
||||
'slides': slides.map((slide) {
|
||||
return slide.toMap();
|
||||
}).toList(),
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ManualItem{id:$id,title: $title,titlemm: $titlemm,isBuyer: $isBuyer, slides: $slides}';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
return other.id == this.id;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
int result = 17;
|
||||
result = 37 * result + id.hashCode;
|
||||
return result;
|
||||
}
|
||||
|
||||
factory ManualItem.clone(ManualItem m) {
|
||||
return ManualItem(
|
||||
id: m.id,
|
||||
title: m.title,
|
||||
titlemm: m.titlemm,
|
||||
isBuyer: m.isBuyer,
|
||||
slides: m.slides.map((s) => SlideData.clone(s)).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SlideData {
|
||||
int id;
|
||||
String image;
|
||||
String imagemm;
|
||||
List<Instruction> instructions;
|
||||
List<Instruction> instructionsmm;
|
||||
SlideData(
|
||||
{this.id,
|
||||
this.image,
|
||||
this.imagemm,
|
||||
this.instructions,
|
||||
this.instructionsmm});
|
||||
|
||||
factory SlideData.fromJson(Map<String, dynamic> json) {
|
||||
var list = json['instructions'] as List;
|
||||
List<Instruction> instructionList =
|
||||
list.map((i) => Instruction.fromJson(i)).toList();
|
||||
|
||||
var listmm = json['instructionsmm'] as List;
|
||||
List<Instruction> instructionmmList =
|
||||
listmm.map((i) => Instruction.fromJson(i)).toList();
|
||||
return SlideData(
|
||||
id: json['id'],
|
||||
image: json['image'],
|
||||
imagemm: json['imagemm'],
|
||||
instructions: instructionList,
|
||||
instructionsmm: instructionmmList,
|
||||
);
|
||||
}
|
||||
|
||||
factory SlideData.fromMap(Map<String, dynamic> map, int id) {
|
||||
return SlideData(
|
||||
id: id,
|
||||
image: map['image'],
|
||||
imagemm: map['imagemm'],
|
||||
instructions: map['instructions'],
|
||||
instructionsmm: map['instructionsmm'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'image': image,
|
||||
'imagemm': imagemm,
|
||||
'instructions': instructions.map((instruction) {
|
||||
return instruction.toJson();
|
||||
}).toList(),
|
||||
'instructionsmm': instructionsmm.map((instruction) {
|
||||
return instruction.toJson();
|
||||
}).toList(),
|
||||
};
|
||||
Map<String, dynamic> toMap() => {
|
||||
'id': id,
|
||||
'image': image,
|
||||
'imagemm': imagemm,
|
||||
'instructions': instructions.map((instruction) {
|
||||
return instruction.toJson();
|
||||
}).toList(),
|
||||
'instructionsmm': instructionsmm.map((instruction) {
|
||||
return instruction.toJson();
|
||||
}).toList(),
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SlideData{id:$id,image: $image,imagemm: $imagemm, instructions: $instructions,instructionsmm: $instructionsmm,}';
|
||||
}
|
||||
|
||||
factory SlideData.clone(SlideData s) {
|
||||
return SlideData(
|
||||
id: s.id,
|
||||
image: s.image,
|
||||
imagemm: s.imagemm,
|
||||
instructions: s.instructions.map((e) => Instruction.clone(e)).toList(),
|
||||
instructionsmm:
|
||||
s.instructionsmm.map((e) => Instruction.clone(e)).toList());
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
return other.id == this.id;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
int result = 17;
|
||||
result = 37 * result + id.hashCode;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class Instruction {
|
||||
int id;
|
||||
String text;
|
||||
double top;
|
||||
double left;
|
||||
Instruction({this.id, this.text, this.top, this.left});
|
||||
factory Instruction.fromJson(Map<String, dynamic> json) {
|
||||
return Instruction(
|
||||
id: json['id'] == null ? 0 : json['id'],
|
||||
text: json['text'] == null ? "" : json['text'],
|
||||
top: double.parse(json['top'].toString()),
|
||||
left: double.parse(json['left'].toString()),
|
||||
);
|
||||
}
|
||||
|
||||
factory Instruction.fromMap(Map<String, dynamic> map, int id) {
|
||||
return Instruction(
|
||||
id: id,
|
||||
text: map['text'],
|
||||
top: map['top'],
|
||||
left: map['left'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'text': text,
|
||||
'top': top,
|
||||
'left': left,
|
||||
};
|
||||
Map<String, dynamic> toMap() => {
|
||||
'id': id,
|
||||
'text': text,
|
||||
'top': top,
|
||||
'left': left,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Instruction{id: $id,text: $text,top: $top, left: $left}';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
return other.id == this.id;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
int result = 17;
|
||||
result = 37 * result + id.hashCode;
|
||||
return result;
|
||||
}
|
||||
|
||||
factory Instruction.clone(Instruction i) {
|
||||
return Instruction(id: i.id, text: i.text, top: i.top, left: i.left);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user