Skip to content

Instantly share code, notes, and snippets.

@Jahidul007
Created September 28, 2021 13:56
Show Gist options
  • Save Jahidul007/08fdc9daa5b7bb540ac255c8074c2ace to your computer and use it in GitHub Desktop.
Save Jahidul007/08fdc9daa5b7bb540ac255c8074c2ace to your computer and use it in GitHub Desktop.
void main() {
var mapData = [
{
"id": 1072,
"title": "Magnetism Doit Chapter 1",
"gradeName": "Eight",
"subjectName": "Science",
"videoUrl": "hyRSO5RR3wo",
"status": false,
"createdDate": "2020-07-04 15:07:13",
"admin": false
},
{
"id": 1072,
"title": "Magnetism Doit Chapter 1",
"gradeName": "Eight",
"subjectName": "Science",
"videoUrl": "hyRSO5RR3wo",
"status": false,
"createdDate": "2020-07-04 15:07:13",
"admin": false
},
];
// print data list
mapData.map((element)=>print(ListItem.fromJson(element).title)).toList();
// store data list
List<ListItem> queryData = mapData.map((element)=>ListItem.fromJson(element)).toList();
print(queryData);
}
class ListItem{
int id;
String title;
String gradeName;
String subjectName;
String videoUrl;
bool status;
String createdDate;
bool admin;
ListItem(
{this.id,
this.title,
this.gradeName,
this.subjectName,
this.videoUrl,
this.status,
this.createdDate,
this.admin});
ListItem.fromJson(Map<String, dynamic> json) {
id = json['id'];
title = json['title'];
gradeName = json['gradeName'];
subjectName = json['subjectName'];
videoUrl = json['videoUrl'];
status = json['status'];
createdDate = json['createdDate'];
admin = json['admin'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['title'] = this.title;
data['gradeName'] = this.gradeName;
data['subjectName'] = this.subjectName;
data['videoUrl'] = this.videoUrl;
data['status'] = this.status;
data['createdDate'] = this.createdDate;
data['admin'] = this.admin;
return data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment