1factory YoutubeResponse.fromJSON(Map<String, dynamic> YoutubeResponseJson)
2 {
3
4// Below 2 line code is parsing JSON Array of items in our JSON Object (YouttubeResponse)
5
6
7var list = YoutubeResponseJson['items'] as List;
8List<Item> itemsList = list.map((i) => Item.fromJSON(i)).toList();
9
10return new YoutubeResponse(
11 kind: YoutubeResponseJson['kind'],
12 etag: YoutubeResponseJson['etag'],
13 nextPageToken: YoutubeResponseJson['nextPageToken'],
14 regionCode: YoutubeResponseJson['regionCode'],
15 mPageInfo: pageInfo.fromJSON(YoutubeResponseJson['pageInfo']),
16
17 // Here we are returning parsed JSON Array.
18
19 items: itemsList);
20
21 }
22