Make ChannelAboutPage's description, viewCount, joinDate and country nullable. Fix #192
This commit is contained in:
parent
968d750408
commit
60f62f1ad6
|
@ -10,14 +10,14 @@ part 'channel_about.freezed.dart';
|
||||||
class ChannelAbout with _$ChannelAbout {
|
class ChannelAbout with _$ChannelAbout {
|
||||||
const factory ChannelAbout(
|
const factory ChannelAbout(
|
||||||
/// Full channel description.
|
/// Full channel description.
|
||||||
String description,
|
String? description,
|
||||||
|
|
||||||
/// Channel view count.
|
/// Channel view count.
|
||||||
int viewCount,
|
int? viewCount,
|
||||||
|
|
||||||
/// Channel join date.
|
/// Channel join date.
|
||||||
/// Formatted as: Gen 01, 2000
|
/// Formatted as: Gen 01, 2000
|
||||||
String joinDate,
|
String? joinDate,
|
||||||
|
|
||||||
/// Channel title.
|
/// Channel title.
|
||||||
String title,
|
String title,
|
||||||
|
@ -26,7 +26,7 @@ class ChannelAbout with _$ChannelAbout {
|
||||||
List<Thumbnail> thumbnails,
|
List<Thumbnail> thumbnails,
|
||||||
|
|
||||||
/// Channel country.
|
/// Channel country.
|
||||||
String country,
|
String? country,
|
||||||
|
|
||||||
/// Channel links.
|
/// Channel links.
|
||||||
List<ChannelLink> channelLinks,
|
List<ChannelLink> channelLinks,
|
||||||
|
|
|
@ -19,12 +19,12 @@ class _$ChannelAboutTearOff {
|
||||||
const _$ChannelAboutTearOff();
|
const _$ChannelAboutTearOff();
|
||||||
|
|
||||||
_ChannelAbout call(
|
_ChannelAbout call(
|
||||||
String description,
|
String? description,
|
||||||
int viewCount,
|
int? viewCount,
|
||||||
String joinDate,
|
String? joinDate,
|
||||||
String title,
|
String title,
|
||||||
List<Thumbnail> thumbnails,
|
List<Thumbnail> thumbnails,
|
||||||
String country,
|
String? country,
|
||||||
List<ChannelLink> channelLinks) {
|
List<ChannelLink> channelLinks) {
|
||||||
return _ChannelAbout(
|
return _ChannelAbout(
|
||||||
description,
|
description,
|
||||||
|
@ -44,14 +44,14 @@ const $ChannelAbout = _$ChannelAboutTearOff();
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$ChannelAbout {
|
mixin _$ChannelAbout {
|
||||||
/// Full channel description.
|
/// Full channel description.
|
||||||
String get description => throw _privateConstructorUsedError;
|
String? get description => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Channel view count.
|
/// Channel view count.
|
||||||
int get viewCount => throw _privateConstructorUsedError;
|
int? get viewCount => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Channel join date.
|
/// Channel join date.
|
||||||
/// Formatted as: Gen 01, 2000
|
/// Formatted as: Gen 01, 2000
|
||||||
String get joinDate => throw _privateConstructorUsedError;
|
String? get joinDate => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Channel title.
|
/// Channel title.
|
||||||
String get title => throw _privateConstructorUsedError;
|
String get title => throw _privateConstructorUsedError;
|
||||||
|
@ -60,7 +60,7 @@ mixin _$ChannelAbout {
|
||||||
List<Thumbnail> get thumbnails => throw _privateConstructorUsedError;
|
List<Thumbnail> get thumbnails => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Channel country.
|
/// Channel country.
|
||||||
String get country => throw _privateConstructorUsedError;
|
String? get country => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Channel links.
|
/// Channel links.
|
||||||
List<ChannelLink> get channelLinks => throw _privateConstructorUsedError;
|
List<ChannelLink> get channelLinks => throw _privateConstructorUsedError;
|
||||||
|
@ -76,12 +76,12 @@ abstract class $ChannelAboutCopyWith<$Res> {
|
||||||
ChannelAbout value, $Res Function(ChannelAbout) then) =
|
ChannelAbout value, $Res Function(ChannelAbout) then) =
|
||||||
_$ChannelAboutCopyWithImpl<$Res>;
|
_$ChannelAboutCopyWithImpl<$Res>;
|
||||||
$Res call(
|
$Res call(
|
||||||
{String description,
|
{String? description,
|
||||||
int viewCount,
|
int? viewCount,
|
||||||
String joinDate,
|
String? joinDate,
|
||||||
String title,
|
String title,
|
||||||
List<Thumbnail> thumbnails,
|
List<Thumbnail> thumbnails,
|
||||||
String country,
|
String? country,
|
||||||
List<ChannelLink> channelLinks});
|
List<ChannelLink> channelLinks});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,15 +107,15 @@ class _$ChannelAboutCopyWithImpl<$Res> implements $ChannelAboutCopyWith<$Res> {
|
||||||
description: description == freezed
|
description: description == freezed
|
||||||
? _value.description
|
? _value.description
|
||||||
: description // ignore: cast_nullable_to_non_nullable
|
: description // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String?,
|
||||||
viewCount: viewCount == freezed
|
viewCount: viewCount == freezed
|
||||||
? _value.viewCount
|
? _value.viewCount
|
||||||
: viewCount // ignore: cast_nullable_to_non_nullable
|
: viewCount // ignore: cast_nullable_to_non_nullable
|
||||||
as int,
|
as int?,
|
||||||
joinDate: joinDate == freezed
|
joinDate: joinDate == freezed
|
||||||
? _value.joinDate
|
? _value.joinDate
|
||||||
: joinDate // ignore: cast_nullable_to_non_nullable
|
: joinDate // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String?,
|
||||||
title: title == freezed
|
title: title == freezed
|
||||||
? _value.title
|
? _value.title
|
||||||
: title // ignore: cast_nullable_to_non_nullable
|
: title // ignore: cast_nullable_to_non_nullable
|
||||||
|
@ -127,7 +127,7 @@ class _$ChannelAboutCopyWithImpl<$Res> implements $ChannelAboutCopyWith<$Res> {
|
||||||
country: country == freezed
|
country: country == freezed
|
||||||
? _value.country
|
? _value.country
|
||||||
: country // ignore: cast_nullable_to_non_nullable
|
: country // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String?,
|
||||||
channelLinks: channelLinks == freezed
|
channelLinks: channelLinks == freezed
|
||||||
? _value.channelLinks
|
? _value.channelLinks
|
||||||
: channelLinks // ignore: cast_nullable_to_non_nullable
|
: channelLinks // ignore: cast_nullable_to_non_nullable
|
||||||
|
@ -144,12 +144,12 @@ abstract class _$ChannelAboutCopyWith<$Res>
|
||||||
__$ChannelAboutCopyWithImpl<$Res>;
|
__$ChannelAboutCopyWithImpl<$Res>;
|
||||||
@override
|
@override
|
||||||
$Res call(
|
$Res call(
|
||||||
{String description,
|
{String? description,
|
||||||
int viewCount,
|
int? viewCount,
|
||||||
String joinDate,
|
String? joinDate,
|
||||||
String title,
|
String title,
|
||||||
List<Thumbnail> thumbnails,
|
List<Thumbnail> thumbnails,
|
||||||
String country,
|
String? country,
|
||||||
List<ChannelLink> channelLinks});
|
List<ChannelLink> channelLinks});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,15 +177,15 @@ class __$ChannelAboutCopyWithImpl<$Res> extends _$ChannelAboutCopyWithImpl<$Res>
|
||||||
description == freezed
|
description == freezed
|
||||||
? _value.description
|
? _value.description
|
||||||
: description // ignore: cast_nullable_to_non_nullable
|
: description // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String?,
|
||||||
viewCount == freezed
|
viewCount == freezed
|
||||||
? _value.viewCount
|
? _value.viewCount
|
||||||
: viewCount // ignore: cast_nullable_to_non_nullable
|
: viewCount // ignore: cast_nullable_to_non_nullable
|
||||||
as int,
|
as int?,
|
||||||
joinDate == freezed
|
joinDate == freezed
|
||||||
? _value.joinDate
|
? _value.joinDate
|
||||||
: joinDate // ignore: cast_nullable_to_non_nullable
|
: joinDate // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String?,
|
||||||
title == freezed
|
title == freezed
|
||||||
? _value.title
|
? _value.title
|
||||||
: title // ignore: cast_nullable_to_non_nullable
|
: title // ignore: cast_nullable_to_non_nullable
|
||||||
|
@ -197,7 +197,7 @@ class __$ChannelAboutCopyWithImpl<$Res> extends _$ChannelAboutCopyWithImpl<$Res>
|
||||||
country == freezed
|
country == freezed
|
||||||
? _value.country
|
? _value.country
|
||||||
: country // ignore: cast_nullable_to_non_nullable
|
: country // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String?,
|
||||||
channelLinks == freezed
|
channelLinks == freezed
|
||||||
? _value.channelLinks
|
? _value.channelLinks
|
||||||
: channelLinks // ignore: cast_nullable_to_non_nullable
|
: channelLinks // ignore: cast_nullable_to_non_nullable
|
||||||
|
@ -215,16 +215,16 @@ class _$_ChannelAbout implements _ChannelAbout {
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Full channel description.
|
/// Full channel description.
|
||||||
final String description;
|
final String? description;
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel view count.
|
/// Channel view count.
|
||||||
final int viewCount;
|
final int? viewCount;
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel join date.
|
/// Channel join date.
|
||||||
/// Formatted as: Gen 01, 2000
|
/// Formatted as: Gen 01, 2000
|
||||||
final String joinDate;
|
final String? joinDate;
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel title.
|
/// Channel title.
|
||||||
|
@ -236,7 +236,7 @@ class _$_ChannelAbout implements _ChannelAbout {
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel country.
|
/// Channel country.
|
||||||
final String country;
|
final String? country;
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel links.
|
/// Channel links.
|
||||||
|
@ -283,27 +283,27 @@ class _$_ChannelAbout implements _ChannelAbout {
|
||||||
|
|
||||||
abstract class _ChannelAbout implements ChannelAbout {
|
abstract class _ChannelAbout implements ChannelAbout {
|
||||||
const factory _ChannelAbout(
|
const factory _ChannelAbout(
|
||||||
String description,
|
String? description,
|
||||||
int viewCount,
|
int? viewCount,
|
||||||
String joinDate,
|
String? joinDate,
|
||||||
String title,
|
String title,
|
||||||
List<Thumbnail> thumbnails,
|
List<Thumbnail> thumbnails,
|
||||||
String country,
|
String? country,
|
||||||
List<ChannelLink> channelLinks) = _$_ChannelAbout;
|
List<ChannelLink> channelLinks) = _$_ChannelAbout;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Full channel description.
|
/// Full channel description.
|
||||||
String get description;
|
String? get description;
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel view count.
|
/// Channel view count.
|
||||||
int get viewCount;
|
int? get viewCount;
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel join date.
|
/// Channel join date.
|
||||||
/// Formatted as: Gen 01, 2000
|
/// Formatted as: Gen 01, 2000
|
||||||
String get joinDate;
|
String? get joinDate;
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel title.
|
/// Channel title.
|
||||||
|
@ -315,7 +315,7 @@ abstract class _ChannelAbout implements ChannelAbout {
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel country.
|
/// Channel country.
|
||||||
String get country;
|
String? get country;
|
||||||
@override
|
@override
|
||||||
|
|
||||||
/// Channel links.
|
/// Channel links.
|
||||||
|
|
|
@ -10,13 +10,13 @@ import '../models/youtube_page.dart';
|
||||||
///
|
///
|
||||||
class ChannelAboutPage extends YoutubePage<_InitialData> {
|
class ChannelAboutPage extends YoutubePage<_InitialData> {
|
||||||
///
|
///
|
||||||
String get description => initialData.description;
|
String? get description => initialData.description;
|
||||||
|
|
||||||
///
|
///
|
||||||
int get viewCount => initialData.viewCount;
|
int? get viewCount => initialData.viewCount;
|
||||||
|
|
||||||
///
|
///
|
||||||
String get joinDate => initialData.joinDate;
|
String? get joinDate => initialData.joinDate;
|
||||||
|
|
||||||
///
|
///
|
||||||
String get title => initialData.title;
|
String get title => initialData.title;
|
||||||
|
@ -25,7 +25,7 @@ class ChannelAboutPage extends YoutubePage<_InitialData> {
|
||||||
List<JsonMap> get avatar => initialData.avatar;
|
List<JsonMap> get avatar => initialData.avatar;
|
||||||
|
|
||||||
///
|
///
|
||||||
String get country => initialData.country;
|
String? get country => initialData.country;
|
||||||
|
|
||||||
///
|
///
|
||||||
List<ChannelLink> get channelLinks => initialData.channelLinks;
|
List<ChannelLink> get channelLinks => initialData.channelLinks;
|
||||||
|
@ -84,8 +84,8 @@ class _InitialData extends InitialData {
|
||||||
.get('channelAboutFullMetadataRenderer')!;
|
.get('channelAboutFullMetadataRenderer')!;
|
||||||
}
|
}
|
||||||
|
|
||||||
late final String description =
|
late final String? description =
|
||||||
content.get('description')!.getT<String>('simpleText')!;
|
content.get('description')?.getT<String>('simpleText');
|
||||||
|
|
||||||
late final List<ChannelLink> channelLinks = content
|
late final List<ChannelLink> channelLinks = content
|
||||||
.getList('primaryLinks')
|
.getList('primaryLinks')
|
||||||
|
@ -110,21 +110,21 @@ class _InitialData extends InitialData {
|
||||||
.toList() ??
|
.toList() ??
|
||||||
[];
|
[];
|
||||||
|
|
||||||
late final int viewCount = int.parse(content
|
late final int? viewCount = content
|
||||||
.get('viewCountText')!
|
.get('viewCountText')
|
||||||
.getT<String>('simpleText')!
|
?.getT<String>('simpleText')
|
||||||
.stripNonDigits());
|
?.parseInt();
|
||||||
|
|
||||||
late final String joinDate =
|
late final String? joinDate =
|
||||||
content.get('joinedDateText')!.getList('runs')![1].getT<String>('text')!;
|
content.get('joinedDateText')?.getList('runs')?[1].getT<String>('text');
|
||||||
|
|
||||||
late final String title = content.get('title')!.getT<String>('simpleText')!;
|
late final String title = content.get('title')!.getT<String>('simpleText')!;
|
||||||
|
|
||||||
late final List<JsonMap> avatar =
|
late final List<JsonMap> avatar =
|
||||||
content.get('avatar')!.getList('thumbnails')!;
|
content.get('avatar')!.getList('thumbnails')!;
|
||||||
|
|
||||||
late final String country =
|
late final String? country =
|
||||||
content.get('country')!.getT<String>('simpleText')!;
|
content.get('country')?.getT<String>('simpleText');
|
||||||
|
|
||||||
Uri extractUrl(String text) =>
|
Uri extractUrl(String text) =>
|
||||||
Uri.parse(Uri.decodeFull(_urlExp.firstMatch(text)?.group(1) ?? ''));
|
Uri.parse(Uri.decodeFull(_urlExp.firstMatch(text)?.group(1) ?? ''));
|
||||||
|
|
Loading…
Reference in New Issue