YT_API constructor

YT_API(
  1. dynamic data, {
  2. bool getTrendingVideo = false,
})

Implementation

YT_API(dynamic data, {bool getTrendingVideo: false}) {
  thumbnail = {
    'default': data['snippet']['thumbnails']['default'],
    'medium': data['snippet']['thumbnails']['medium'],
    'high': data['snippet']['thumbnails']['high']
  };
  if (getTrendingVideo) {
    kind = 'video'; //data['kind'].substring(8)
    id = data['id'];
  } else {
    kind = data['id']['kind'].substring(8);
    id = data['id'][data['id'].keys.elementAt(1)];
  }
  url = getURL(kind!, id!);
  publishedAt = data['snippet']['publishedAt'];
  channelId = data['snippet']['channelId'];
  channelUrl = "https://www.youtube.com/channel/$channelId";
  title = data['snippet']['title'];
  description = data['snippet']['description'];
  channelTitle = data['snippet']['channelTitle'];
}