Initial Commit
This commit is contained in:
37
lib/models/channel.dart
Normal file
37
lib/models/channel.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
class Channel {
|
||||
final int id;
|
||||
final String name;
|
||||
final String? description;
|
||||
final String? photoBaseUrl;
|
||||
final String? link;
|
||||
final String? webApp;
|
||||
final List<String> options;
|
||||
final int updateTime;
|
||||
|
||||
Channel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.description,
|
||||
this.photoBaseUrl,
|
||||
this.link,
|
||||
this.webApp,
|
||||
required this.options,
|
||||
required this.updateTime,
|
||||
});
|
||||
|
||||
factory Channel.fromJson(Map<String, dynamic> json) {
|
||||
final names = json['names'] as List<dynamic>?;
|
||||
final nameData = names?.isNotEmpty == true ? names![0] : null;
|
||||
|
||||
return Channel(
|
||||
id: json['id'] as int,
|
||||
name: nameData?['name'] as String? ?? 'Неизвестный канал',
|
||||
description: nameData?['description'] as String?,
|
||||
photoBaseUrl: json['baseUrl'] as String?,
|
||||
link: json['link'] as String?,
|
||||
webApp: json['webApp'] as String?,
|
||||
options: List<String>.from(json['options'] ?? []),
|
||||
updateTime: json['updateTime'] as int? ?? 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user