Migrate from `package:equatable` to `freezed`

This commit is contained in:
Mattia 2021-07-19 00:47:22 +02:00
parent 0949bb13c1
commit 3b530c7ee4
54 changed files with 5728 additions and 519 deletions

View File

@ -11,3 +11,4 @@ linter:
parameter_assignments: false
no_runtimetype_tostring: false
avoid_escaping_inner_quotes: false
prefer_const_constructors: true

View File

@ -1,30 +1,28 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'channel_id.dart';
part 'channel.freezed.dart';
/// YouTube channel metadata.
class Channel with EquatableMixin {
/// Channel ID.
final ChannelId id;
@Freezed()
class Channel with _$Channel {
const Channel._();
const factory Channel(
/// Channel ID.
ChannelId id,
/// Channel title.
String title,
/// URL of the channel's logo image.
String logoUrl,
/// The (approximate) channel subscriber's count.
int? subscribersCount,
) = _Channel;
/// Channel URL.
String get url => 'https://www.youtube.com/channel/$id';
/// Channel title.
final String title;
/// URL of the channel's logo image.
final String logoUrl;
/// The (approximate) channel subscriber's count.
final int? subscribersCount;
/// Initializes an instance of [Channel]
Channel(this.id, this.title, this.logoUrl, this.subscribersCount);
@override
String toString() => 'Channel ($title)';
@override
List<Object> get props => [id];
}

View File

@ -0,0 +1,237 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'channel.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$ChannelTearOff {
const _$ChannelTearOff();
_Channel call(
ChannelId id, String title, String logoUrl, int? subscribersCount) {
return _Channel(
id,
title,
logoUrl,
subscribersCount,
);
}
}
/// @nodoc
const $Channel = _$ChannelTearOff();
/// @nodoc
mixin _$Channel {
/// Channel ID.
ChannelId get id => throw _privateConstructorUsedError;
/// Channel title.
String get title => throw _privateConstructorUsedError;
/// URL of the channel's logo image.
String get logoUrl => throw _privateConstructorUsedError;
/// The (approximate) channel subscriber's count.
int? get subscribersCount => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChannelCopyWith<Channel> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChannelCopyWith<$Res> {
factory $ChannelCopyWith(Channel value, $Res Function(Channel) then) =
_$ChannelCopyWithImpl<$Res>;
$Res call(
{ChannelId id, String title, String logoUrl, int? subscribersCount});
$ChannelIdCopyWith<$Res> get id;
}
/// @nodoc
class _$ChannelCopyWithImpl<$Res> implements $ChannelCopyWith<$Res> {
_$ChannelCopyWithImpl(this._value, this._then);
final Channel _value;
// ignore: unused_field
final $Res Function(Channel) _then;
@override
$Res call({
Object? id = freezed,
Object? title = freezed,
Object? logoUrl = freezed,
Object? subscribersCount = freezed,
}) {
return _then(_value.copyWith(
id: id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as ChannelId,
title: title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
logoUrl: logoUrl == freezed
? _value.logoUrl
: logoUrl // ignore: cast_nullable_to_non_nullable
as String,
subscribersCount: subscribersCount == freezed
? _value.subscribersCount
: subscribersCount // ignore: cast_nullable_to_non_nullable
as int?,
));
}
@override
$ChannelIdCopyWith<$Res> get id {
return $ChannelIdCopyWith<$Res>(_value.id, (value) {
return _then(_value.copyWith(id: value));
});
}
}
/// @nodoc
abstract class _$ChannelCopyWith<$Res> implements $ChannelCopyWith<$Res> {
factory _$ChannelCopyWith(_Channel value, $Res Function(_Channel) then) =
__$ChannelCopyWithImpl<$Res>;
@override
$Res call(
{ChannelId id, String title, String logoUrl, int? subscribersCount});
@override
$ChannelIdCopyWith<$Res> get id;
}
/// @nodoc
class __$ChannelCopyWithImpl<$Res> extends _$ChannelCopyWithImpl<$Res>
implements _$ChannelCopyWith<$Res> {
__$ChannelCopyWithImpl(_Channel _value, $Res Function(_Channel) _then)
: super(_value, (v) => _then(v as _Channel));
@override
_Channel get _value => super._value as _Channel;
@override
$Res call({
Object? id = freezed,
Object? title = freezed,
Object? logoUrl = freezed,
Object? subscribersCount = freezed,
}) {
return _then(_Channel(
id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as ChannelId,
title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
logoUrl == freezed
? _value.logoUrl
: logoUrl // ignore: cast_nullable_to_non_nullable
as String,
subscribersCount == freezed
? _value.subscribersCount
: subscribersCount // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}
/// @nodoc
class _$_Channel extends _Channel {
const _$_Channel(this.id, this.title, this.logoUrl, this.subscribersCount)
: super._();
@override
/// Channel ID.
final ChannelId id;
@override
/// Channel title.
final String title;
@override
/// URL of the channel's logo image.
final String logoUrl;
@override
/// The (approximate) channel subscriber's count.
final int? subscribersCount;
@override
String toString() {
return 'Channel(id: $id, title: $title, logoUrl: $logoUrl, subscribersCount: $subscribersCount)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _Channel &&
(identical(other.id, id) ||
const DeepCollectionEquality().equals(other.id, id)) &&
(identical(other.title, title) ||
const DeepCollectionEquality().equals(other.title, title)) &&
(identical(other.logoUrl, logoUrl) ||
const DeepCollectionEquality()
.equals(other.logoUrl, logoUrl)) &&
(identical(other.subscribersCount, subscribersCount) ||
const DeepCollectionEquality()
.equals(other.subscribersCount, subscribersCount)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(id) ^
const DeepCollectionEquality().hash(title) ^
const DeepCollectionEquality().hash(logoUrl) ^
const DeepCollectionEquality().hash(subscribersCount);
@JsonKey(ignore: true)
@override
_$ChannelCopyWith<_Channel> get copyWith =>
__$ChannelCopyWithImpl<_Channel>(this, _$identity);
}
abstract class _Channel extends Channel {
const factory _Channel(
ChannelId id, String title, String logoUrl, int? subscribersCount) =
_$_Channel;
const _Channel._() : super._();
@override
/// Channel ID.
ChannelId get id => throw _privateConstructorUsedError;
@override
/// Channel title.
String get title => throw _privateConstructorUsedError;
@override
/// URL of the channel's logo image.
String get logoUrl => throw _privateConstructorUsedError;
@override
/// The (approximate) channel subscriber's count.
int? get subscribersCount => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$ChannelCopyWith<_Channel> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,37 +1,34 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../common/thumbnail.dart';
import 'channel_link.dart';
part 'channel_about.freezed.dart';
/// YouTube channel's about page metadata.
class ChannelAbout with EquatableMixin {
/// Full channel description.
final String description;
@freezed
class ChannelAbout with _$ChannelAbout {
const factory ChannelAbout(
/// Full channel description.
String description,
/// Channel view count.
final int viewCount;
/// Channel view count.
int viewCount,
/// Channel join date.
/// Formatted as: Gen 01, 2000
final String joinDate;
/// Channel join date.
/// Formatted as: Gen 01, 2000
String joinDate,
/// Channel title.
final String title;
/// Channel title.
String title,
/// Channel thumbnails.
final List<Thumbnail> thumbnails;
/// Channel thumbnails.
List<Thumbnail> thumbnails,
/// Channel country.
final String country;
/// Channel country.
String country,
/// Channel links.
final List<ChannelLink> channelLinks;
/// Initialize an instance of [ChannelAbout]
ChannelAbout(this.description, this.viewCount, this.joinDate, this.title,
this.thumbnails, this.country, this.channelLinks);
@override
List<Object> get props =>
[description, viewCount, joinDate, title, thumbnails];
/// Channel links.
List<ChannelLink> channelLinks,
) = _ChannelAbout;
}

View File

@ -0,0 +1,334 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'channel_about.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$ChannelAboutTearOff {
const _$ChannelAboutTearOff();
_ChannelAbout call(
String description,
int viewCount,
String joinDate,
String title,
List<Thumbnail> thumbnails,
String country,
List<ChannelLink> channelLinks) {
return _ChannelAbout(
description,
viewCount,
joinDate,
title,
thumbnails,
country,
channelLinks,
);
}
}
/// @nodoc
const $ChannelAbout = _$ChannelAboutTearOff();
/// @nodoc
mixin _$ChannelAbout {
/// Full channel description.
String get description => throw _privateConstructorUsedError;
/// Channel view count.
int get viewCount => throw _privateConstructorUsedError;
/// Channel join date.
/// Formatted as: Gen 01, 2000
String get joinDate => throw _privateConstructorUsedError;
/// Channel title.
String get title => throw _privateConstructorUsedError;
/// Channel thumbnails.
List<Thumbnail> get thumbnails => throw _privateConstructorUsedError;
/// Channel country.
String get country => throw _privateConstructorUsedError;
/// Channel links.
List<ChannelLink> get channelLinks => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChannelAboutCopyWith<ChannelAbout> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChannelAboutCopyWith<$Res> {
factory $ChannelAboutCopyWith(
ChannelAbout value, $Res Function(ChannelAbout) then) =
_$ChannelAboutCopyWithImpl<$Res>;
$Res call(
{String description,
int viewCount,
String joinDate,
String title,
List<Thumbnail> thumbnails,
String country,
List<ChannelLink> channelLinks});
}
/// @nodoc
class _$ChannelAboutCopyWithImpl<$Res> implements $ChannelAboutCopyWith<$Res> {
_$ChannelAboutCopyWithImpl(this._value, this._then);
final ChannelAbout _value;
// ignore: unused_field
final $Res Function(ChannelAbout) _then;
@override
$Res call({
Object? description = freezed,
Object? viewCount = freezed,
Object? joinDate = freezed,
Object? title = freezed,
Object? thumbnails = freezed,
Object? country = freezed,
Object? channelLinks = freezed,
}) {
return _then(_value.copyWith(
description: description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
viewCount: viewCount == freezed
? _value.viewCount
: viewCount // ignore: cast_nullable_to_non_nullable
as int,
joinDate: joinDate == freezed
? _value.joinDate
: joinDate // ignore: cast_nullable_to_non_nullable
as String,
title: title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
thumbnails: thumbnails == freezed
? _value.thumbnails
: thumbnails // ignore: cast_nullable_to_non_nullable
as List<Thumbnail>,
country: country == freezed
? _value.country
: country // ignore: cast_nullable_to_non_nullable
as String,
channelLinks: channelLinks == freezed
? _value.channelLinks
: channelLinks // ignore: cast_nullable_to_non_nullable
as List<ChannelLink>,
));
}
}
/// @nodoc
abstract class _$ChannelAboutCopyWith<$Res>
implements $ChannelAboutCopyWith<$Res> {
factory _$ChannelAboutCopyWith(
_ChannelAbout value, $Res Function(_ChannelAbout) then) =
__$ChannelAboutCopyWithImpl<$Res>;
@override
$Res call(
{String description,
int viewCount,
String joinDate,
String title,
List<Thumbnail> thumbnails,
String country,
List<ChannelLink> channelLinks});
}
/// @nodoc
class __$ChannelAboutCopyWithImpl<$Res> extends _$ChannelAboutCopyWithImpl<$Res>
implements _$ChannelAboutCopyWith<$Res> {
__$ChannelAboutCopyWithImpl(
_ChannelAbout _value, $Res Function(_ChannelAbout) _then)
: super(_value, (v) => _then(v as _ChannelAbout));
@override
_ChannelAbout get _value => super._value as _ChannelAbout;
@override
$Res call({
Object? description = freezed,
Object? viewCount = freezed,
Object? joinDate = freezed,
Object? title = freezed,
Object? thumbnails = freezed,
Object? country = freezed,
Object? channelLinks = freezed,
}) {
return _then(_ChannelAbout(
description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
viewCount == freezed
? _value.viewCount
: viewCount // ignore: cast_nullable_to_non_nullable
as int,
joinDate == freezed
? _value.joinDate
: joinDate // ignore: cast_nullable_to_non_nullable
as String,
title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
thumbnails == freezed
? _value.thumbnails
: thumbnails // ignore: cast_nullable_to_non_nullable
as List<Thumbnail>,
country == freezed
? _value.country
: country // ignore: cast_nullable_to_non_nullable
as String,
channelLinks == freezed
? _value.channelLinks
: channelLinks // ignore: cast_nullable_to_non_nullable
as List<ChannelLink>,
));
}
}
/// @nodoc
class _$_ChannelAbout implements _ChannelAbout {
const _$_ChannelAbout(this.description, this.viewCount, this.joinDate,
this.title, this.thumbnails, this.country, this.channelLinks);
@override
/// Full channel description.
final String description;
@override
/// Channel view count.
final int viewCount;
@override
/// Channel join date.
/// Formatted as: Gen 01, 2000
final String joinDate;
@override
/// Channel title.
final String title;
@override
/// Channel thumbnails.
final List<Thumbnail> thumbnails;
@override
/// Channel country.
final String country;
@override
/// Channel links.
final List<ChannelLink> channelLinks;
@override
String toString() {
return 'ChannelAbout(description: $description, viewCount: $viewCount, joinDate: $joinDate, title: $title, thumbnails: $thumbnails, country: $country, channelLinks: $channelLinks)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _ChannelAbout &&
(identical(other.description, description) ||
const DeepCollectionEquality()
.equals(other.description, description)) &&
(identical(other.viewCount, viewCount) ||
const DeepCollectionEquality()
.equals(other.viewCount, viewCount)) &&
(identical(other.joinDate, joinDate) ||
const DeepCollectionEquality()
.equals(other.joinDate, joinDate)) &&
(identical(other.title, title) ||
const DeepCollectionEquality().equals(other.title, title)) &&
(identical(other.thumbnails, thumbnails) ||
const DeepCollectionEquality()
.equals(other.thumbnails, thumbnails)) &&
(identical(other.country, country) ||
const DeepCollectionEquality()
.equals(other.country, country)) &&
(identical(other.channelLinks, channelLinks) ||
const DeepCollectionEquality()
.equals(other.channelLinks, channelLinks)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(description) ^
const DeepCollectionEquality().hash(viewCount) ^
const DeepCollectionEquality().hash(joinDate) ^
const DeepCollectionEquality().hash(title) ^
const DeepCollectionEquality().hash(thumbnails) ^
const DeepCollectionEquality().hash(country) ^
const DeepCollectionEquality().hash(channelLinks);
@JsonKey(ignore: true)
@override
_$ChannelAboutCopyWith<_ChannelAbout> get copyWith =>
__$ChannelAboutCopyWithImpl<_ChannelAbout>(this, _$identity);
}
abstract class _ChannelAbout implements ChannelAbout {
const factory _ChannelAbout(
String description,
int viewCount,
String joinDate,
String title,
List<Thumbnail> thumbnails,
String country,
List<ChannelLink> channelLinks) = _$_ChannelAbout;
@override
/// Full channel description.
String get description => throw _privateConstructorUsedError;
@override
/// Channel view count.
int get viewCount => throw _privateConstructorUsedError;
@override
/// Channel join date.
/// Formatted as: Gen 01, 2000
String get joinDate => throw _privateConstructorUsedError;
@override
/// Channel title.
String get title => throw _privateConstructorUsedError;
@override
/// Channel thumbnails.
List<Thumbnail> get thumbnails => throw _privateConstructorUsedError;
@override
/// Channel country.
String get country => throw _privateConstructorUsedError;
@override
/// Channel links.
List<ChannelLink> get channelLinks => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$ChannelAboutCopyWith<_ChannelAbout> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -21,7 +21,7 @@ class ChannelClient {
final YoutubeHttpClient _httpClient;
/// Initializes an instance of [ChannelClient]
ChannelClient(this._httpClient);
const ChannelClient(this._httpClient);
/// Gets the metadata associated with the specified channel.
/// [id] must be either a [ChannelId] or a string

View File

@ -1,18 +1,41 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../extensions/helpers_extension.dart';
/// Encapsulates a valid YouTube channel ID.
class ChannelId with EquatableMixin {
/// ID as a string.
final String value;
part 'channel_id.freezed.dart';
/// Encapsulates a valid YouTube channel ID.
@freezed
class ChannelId with _$ChannelId {
/// Initializes an instance of [ChannelId]
ChannelId(String value) : value = parseChannelId(value) ?? '' {
factory ChannelId(String value) {
final id = parseChannelId(value);
if (id == null) {
throw ArgumentError.value(value, 'value', 'Invalid channel id');
}
return ChannelId._internal(id);
}
const factory ChannelId._internal(
/// ID as a string.
String value) = _ChannelId;
const ChannelId._();
/// Converts [obj] to a [ChannelId] by calling .toString on that object.
/// If it is already a [ChannelId], [obj] is returned
factory ChannelId.fromString(dynamic obj) {
if (obj is ChannelId) {
return obj;
}
return ChannelId(obj.toString());
}
/* ChannelId(String value) : value = parseChannelId(value) ?? '' {
if (this.value.isEmpty) {
throw ArgumentError.value(value);
}
}
}*/
/// Returns true if the given id is a valid channel id.
static bool validateChannelId(String id) {
@ -51,18 +74,6 @@ class ChannelId with EquatableMixin {
return null;
}
/// Converts [obj] to a [ChannelId] by calling .toString on that object.
/// If it is already a [ChannelId], [obj] is returned
factory ChannelId.fromString(dynamic obj) {
if (obj is ChannelId) {
return obj;
}
return ChannelId(obj.toString());
}
@override
String toString() => value;
@override
List<Object> get props => [value];
}

View File

@ -0,0 +1,138 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'channel_id.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$ChannelIdTearOff {
const _$ChannelIdTearOff();
_ChannelId _internal(String value) {
return _ChannelId(
value,
);
}
}
/// @nodoc
const $ChannelId = _$ChannelIdTearOff();
/// @nodoc
mixin _$ChannelId {
/// ID as a string.
String get value => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChannelIdCopyWith<ChannelId> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChannelIdCopyWith<$Res> {
factory $ChannelIdCopyWith(ChannelId value, $Res Function(ChannelId) then) =
_$ChannelIdCopyWithImpl<$Res>;
$Res call({String value});
}
/// @nodoc
class _$ChannelIdCopyWithImpl<$Res> implements $ChannelIdCopyWith<$Res> {
_$ChannelIdCopyWithImpl(this._value, this._then);
final ChannelId _value;
// ignore: unused_field
final $Res Function(ChannelId) _then;
@override
$Res call({
Object? value = freezed,
}) {
return _then(_value.copyWith(
value: value == freezed
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
abstract class _$ChannelIdCopyWith<$Res> implements $ChannelIdCopyWith<$Res> {
factory _$ChannelIdCopyWith(
_ChannelId value, $Res Function(_ChannelId) then) =
__$ChannelIdCopyWithImpl<$Res>;
@override
$Res call({String value});
}
/// @nodoc
class __$ChannelIdCopyWithImpl<$Res> extends _$ChannelIdCopyWithImpl<$Res>
implements _$ChannelIdCopyWith<$Res> {
__$ChannelIdCopyWithImpl(_ChannelId _value, $Res Function(_ChannelId) _then)
: super(_value, (v) => _then(v as _ChannelId));
@override
_ChannelId get _value => super._value as _ChannelId;
@override
$Res call({
Object? value = freezed,
}) {
return _then(_ChannelId(
value == freezed
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$_ChannelId extends _ChannelId {
const _$_ChannelId(this.value) : super._();
@override
/// ID as a string.
final String value;
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _ChannelId &&
(identical(other.value, value) ||
const DeepCollectionEquality().equals(other.value, value)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(value);
@JsonKey(ignore: true)
@override
_$ChannelIdCopyWith<_ChannelId> get copyWith =>
__$ChannelIdCopyWithImpl<_ChannelId>(this, _$identity);
}
abstract class _ChannelId extends ChannelId {
const factory _ChannelId(String value) = _$_ChannelId;
const _ChannelId._() : super._();
@override
/// ID as a string.
String get value => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$ChannelIdCopyWith<_ChannelId> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,23 +1,20 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'channel_link.freezed.dart';
/// Represents a channel link.
class ChannelLink with EquatableMixin {
/// Link title.
final String title;
/// Link URL.
/// Already decoded with the YouTube shortener already taken out.
final Uri url;
/// Link Icon URL.
final Uri icon;
@freezed
class ChannelLink with _$ChannelLink {
/// Initialize an instance of [ChannelLink]
ChannelLink(this.title, this.url, this.icon);
const factory ChannelLink(
/// Link title.
String title,
@override
List<Object> get props => [title, url, icon];
/// Link URL.
/// Already decoded with the YouTube shortener already taken out.
Uri url,
@override
String toString() => 'Link: $title ($url): $icon';
/// Link Icon URL.
Uri icon,
) = _ChannelLink;
}

View File

@ -0,0 +1,199 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'channel_link.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$ChannelLinkTearOff {
const _$ChannelLinkTearOff();
_ChannelLink call(String title, Uri url, Uri icon) {
return _ChannelLink(
title,
url,
icon,
);
}
}
/// @nodoc
const $ChannelLink = _$ChannelLinkTearOff();
/// @nodoc
mixin _$ChannelLink {
/// Link title.
String get title => throw _privateConstructorUsedError;
/// Link URL.
/// Already decoded with the YouTube shortener already taken out.
Uri get url => throw _privateConstructorUsedError;
/// Link Icon URL.
Uri get icon => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChannelLinkCopyWith<ChannelLink> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChannelLinkCopyWith<$Res> {
factory $ChannelLinkCopyWith(
ChannelLink value, $Res Function(ChannelLink) then) =
_$ChannelLinkCopyWithImpl<$Res>;
$Res call({String title, Uri url, Uri icon});
}
/// @nodoc
class _$ChannelLinkCopyWithImpl<$Res> implements $ChannelLinkCopyWith<$Res> {
_$ChannelLinkCopyWithImpl(this._value, this._then);
final ChannelLink _value;
// ignore: unused_field
final $Res Function(ChannelLink) _then;
@override
$Res call({
Object? title = freezed,
Object? url = freezed,
Object? icon = freezed,
}) {
return _then(_value.copyWith(
title: title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
url: url == freezed
? _value.url
: url // ignore: cast_nullable_to_non_nullable
as Uri,
icon: icon == freezed
? _value.icon
: icon // ignore: cast_nullable_to_non_nullable
as Uri,
));
}
}
/// @nodoc
abstract class _$ChannelLinkCopyWith<$Res>
implements $ChannelLinkCopyWith<$Res> {
factory _$ChannelLinkCopyWith(
_ChannelLink value, $Res Function(_ChannelLink) then) =
__$ChannelLinkCopyWithImpl<$Res>;
@override
$Res call({String title, Uri url, Uri icon});
}
/// @nodoc
class __$ChannelLinkCopyWithImpl<$Res> extends _$ChannelLinkCopyWithImpl<$Res>
implements _$ChannelLinkCopyWith<$Res> {
__$ChannelLinkCopyWithImpl(
_ChannelLink _value, $Res Function(_ChannelLink) _then)
: super(_value, (v) => _then(v as _ChannelLink));
@override
_ChannelLink get _value => super._value as _ChannelLink;
@override
$Res call({
Object? title = freezed,
Object? url = freezed,
Object? icon = freezed,
}) {
return _then(_ChannelLink(
title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
url == freezed
? _value.url
: url // ignore: cast_nullable_to_non_nullable
as Uri,
icon == freezed
? _value.icon
: icon // ignore: cast_nullable_to_non_nullable
as Uri,
));
}
}
/// @nodoc
class _$_ChannelLink implements _ChannelLink {
const _$_ChannelLink(this.title, this.url, this.icon);
@override
/// Link title.
final String title;
@override
/// Link URL.
/// Already decoded with the YouTube shortener already taken out.
final Uri url;
@override
/// Link Icon URL.
final Uri icon;
@override
String toString() {
return 'ChannelLink(title: $title, url: $url, icon: $icon)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _ChannelLink &&
(identical(other.title, title) ||
const DeepCollectionEquality().equals(other.title, title)) &&
(identical(other.url, url) ||
const DeepCollectionEquality().equals(other.url, url)) &&
(identical(other.icon, icon) ||
const DeepCollectionEquality().equals(other.icon, icon)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(title) ^
const DeepCollectionEquality().hash(url) ^
const DeepCollectionEquality().hash(icon);
@JsonKey(ignore: true)
@override
_$ChannelLinkCopyWith<_ChannelLink> get copyWith =>
__$ChannelLinkCopyWithImpl<_ChannelLink>(this, _$identity);
}
abstract class _ChannelLink implements ChannelLink {
const factory _ChannelLink(String title, Uri url, Uri icon) = _$_ChannelLink;
@override
/// Link title.
String get title => throw _privateConstructorUsedError;
@override
/// Link URL.
/// Already decoded with the YouTube shortener already taken out.
Uri get url => throw _privateConstructorUsedError;
@override
/// Link Icon URL.
Uri get icon => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$ChannelLinkCopyWith<_ChannelLink> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,35 +1,30 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../videos/video_id.dart';
part 'channel_video.freezed.dart';
/// Metadata related to a search query result (playlist)
class ChannelVideo with EquatableMixin {
/// Video ID.
final VideoId videoId;
@freezed
class ChannelVideo with _$ChannelVideo {
const factory ChannelVideo(
/// Video ID.
VideoId videoId,
/// Video title.
final String videoTitle;
/// Video title.
String videoTitle,
/// Video duration
final Duration videoDuration;
/// Video duration
Duration videoDuration,
/// Video thumbnail
final String videoThumbnail;
/// Video thumbnail
String videoThumbnail,
/// Video upload date.
/// Formatted like 10 hours ago
final String videoUploadDate;
/// Video upload date.
/// Formatted like 10 hours ago
String videoUploadDate,
/// Video view count.
final int videoViews;
/// Initialize an instance of [ChannelVideo]
ChannelVideo(this.videoId, this.videoTitle, this.videoDuration,
this.videoThumbnail, this.videoUploadDate, this.videoViews);
@override
String toString() => '[ChannelVideo] $videoTitle ($videoId)';
@override
List<Object> get props => [videoId];
/// Video view count.
int videoViews,
) = _ChannelVideo;
}

View File

@ -0,0 +1,312 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'channel_video.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$ChannelVideoTearOff {
const _$ChannelVideoTearOff();
_ChannelVideo call(VideoId videoId, String videoTitle, Duration videoDuration,
String videoThumbnail, String videoUploadDate, int videoViews) {
return _ChannelVideo(
videoId,
videoTitle,
videoDuration,
videoThumbnail,
videoUploadDate,
videoViews,
);
}
}
/// @nodoc
const $ChannelVideo = _$ChannelVideoTearOff();
/// @nodoc
mixin _$ChannelVideo {
/// Video ID.
VideoId get videoId => throw _privateConstructorUsedError;
/// Video title.
String get videoTitle => throw _privateConstructorUsedError;
/// Video duration
Duration get videoDuration => throw _privateConstructorUsedError;
/// Video thumbnail
String get videoThumbnail => throw _privateConstructorUsedError;
/// Video upload date.
/// Formatted like 10 hours ago
String get videoUploadDate => throw _privateConstructorUsedError;
/// Video view count.
int get videoViews => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChannelVideoCopyWith<ChannelVideo> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChannelVideoCopyWith<$Res> {
factory $ChannelVideoCopyWith(
ChannelVideo value, $Res Function(ChannelVideo) then) =
_$ChannelVideoCopyWithImpl<$Res>;
$Res call(
{VideoId videoId,
String videoTitle,
Duration videoDuration,
String videoThumbnail,
String videoUploadDate,
int videoViews});
$VideoIdCopyWith<$Res> get videoId;
}
/// @nodoc
class _$ChannelVideoCopyWithImpl<$Res> implements $ChannelVideoCopyWith<$Res> {
_$ChannelVideoCopyWithImpl(this._value, this._then);
final ChannelVideo _value;
// ignore: unused_field
final $Res Function(ChannelVideo) _then;
@override
$Res call({
Object? videoId = freezed,
Object? videoTitle = freezed,
Object? videoDuration = freezed,
Object? videoThumbnail = freezed,
Object? videoUploadDate = freezed,
Object? videoViews = freezed,
}) {
return _then(_value.copyWith(
videoId: videoId == freezed
? _value.videoId
: videoId // ignore: cast_nullable_to_non_nullable
as VideoId,
videoTitle: videoTitle == freezed
? _value.videoTitle
: videoTitle // ignore: cast_nullable_to_non_nullable
as String,
videoDuration: videoDuration == freezed
? _value.videoDuration
: videoDuration // ignore: cast_nullable_to_non_nullable
as Duration,
videoThumbnail: videoThumbnail == freezed
? _value.videoThumbnail
: videoThumbnail // ignore: cast_nullable_to_non_nullable
as String,
videoUploadDate: videoUploadDate == freezed
? _value.videoUploadDate
: videoUploadDate // ignore: cast_nullable_to_non_nullable
as String,
videoViews: videoViews == freezed
? _value.videoViews
: videoViews // ignore: cast_nullable_to_non_nullable
as int,
));
}
@override
$VideoIdCopyWith<$Res> get videoId {
return $VideoIdCopyWith<$Res>(_value.videoId, (value) {
return _then(_value.copyWith(videoId: value));
});
}
}
/// @nodoc
abstract class _$ChannelVideoCopyWith<$Res>
implements $ChannelVideoCopyWith<$Res> {
factory _$ChannelVideoCopyWith(
_ChannelVideo value, $Res Function(_ChannelVideo) then) =
__$ChannelVideoCopyWithImpl<$Res>;
@override
$Res call(
{VideoId videoId,
String videoTitle,
Duration videoDuration,
String videoThumbnail,
String videoUploadDate,
int videoViews});
@override
$VideoIdCopyWith<$Res> get videoId;
}
/// @nodoc
class __$ChannelVideoCopyWithImpl<$Res> extends _$ChannelVideoCopyWithImpl<$Res>
implements _$ChannelVideoCopyWith<$Res> {
__$ChannelVideoCopyWithImpl(
_ChannelVideo _value, $Res Function(_ChannelVideo) _then)
: super(_value, (v) => _then(v as _ChannelVideo));
@override
_ChannelVideo get _value => super._value as _ChannelVideo;
@override
$Res call({
Object? videoId = freezed,
Object? videoTitle = freezed,
Object? videoDuration = freezed,
Object? videoThumbnail = freezed,
Object? videoUploadDate = freezed,
Object? videoViews = freezed,
}) {
return _then(_ChannelVideo(
videoId == freezed
? _value.videoId
: videoId // ignore: cast_nullable_to_non_nullable
as VideoId,
videoTitle == freezed
? _value.videoTitle
: videoTitle // ignore: cast_nullable_to_non_nullable
as String,
videoDuration == freezed
? _value.videoDuration
: videoDuration // ignore: cast_nullable_to_non_nullable
as Duration,
videoThumbnail == freezed
? _value.videoThumbnail
: videoThumbnail // ignore: cast_nullable_to_non_nullable
as String,
videoUploadDate == freezed
? _value.videoUploadDate
: videoUploadDate // ignore: cast_nullable_to_non_nullable
as String,
videoViews == freezed
? _value.videoViews
: videoViews // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
class _$_ChannelVideo implements _ChannelVideo {
const _$_ChannelVideo(this.videoId, this.videoTitle, this.videoDuration,
this.videoThumbnail, this.videoUploadDate, this.videoViews);
@override
/// Video ID.
final VideoId videoId;
@override
/// Video title.
final String videoTitle;
@override
/// Video duration
final Duration videoDuration;
@override
/// Video thumbnail
final String videoThumbnail;
@override
/// Video upload date.
/// Formatted like 10 hours ago
final String videoUploadDate;
@override
/// Video view count.
final int videoViews;
@override
String toString() {
return 'ChannelVideo(videoId: $videoId, videoTitle: $videoTitle, videoDuration: $videoDuration, videoThumbnail: $videoThumbnail, videoUploadDate: $videoUploadDate, videoViews: $videoViews)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _ChannelVideo &&
(identical(other.videoId, videoId) ||
const DeepCollectionEquality()
.equals(other.videoId, videoId)) &&
(identical(other.videoTitle, videoTitle) ||
const DeepCollectionEquality()
.equals(other.videoTitle, videoTitle)) &&
(identical(other.videoDuration, videoDuration) ||
const DeepCollectionEquality()
.equals(other.videoDuration, videoDuration)) &&
(identical(other.videoThumbnail, videoThumbnail) ||
const DeepCollectionEquality()
.equals(other.videoThumbnail, videoThumbnail)) &&
(identical(other.videoUploadDate, videoUploadDate) ||
const DeepCollectionEquality()
.equals(other.videoUploadDate, videoUploadDate)) &&
(identical(other.videoViews, videoViews) ||
const DeepCollectionEquality()
.equals(other.videoViews, videoViews)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(videoId) ^
const DeepCollectionEquality().hash(videoTitle) ^
const DeepCollectionEquality().hash(videoDuration) ^
const DeepCollectionEquality().hash(videoThumbnail) ^
const DeepCollectionEquality().hash(videoUploadDate) ^
const DeepCollectionEquality().hash(videoViews);
@JsonKey(ignore: true)
@override
_$ChannelVideoCopyWith<_ChannelVideo> get copyWith =>
__$ChannelVideoCopyWithImpl<_ChannelVideo>(this, _$identity);
}
abstract class _ChannelVideo implements ChannelVideo {
const factory _ChannelVideo(
VideoId videoId,
String videoTitle,
Duration videoDuration,
String videoThumbnail,
String videoUploadDate,
int videoViews) = _$_ChannelVideo;
@override
/// Video ID.
VideoId get videoId => throw _privateConstructorUsedError;
@override
/// Video title.
String get videoTitle => throw _privateConstructorUsedError;
@override
/// Video duration
Duration get videoDuration => throw _privateConstructorUsedError;
@override
/// Video thumbnail
String get videoThumbnail => throw _privateConstructorUsedError;
@override
/// Video upload date.
/// Formatted like 10 hours ago
String get videoUploadDate => throw _privateConstructorUsedError;
@override
/// Video view count.
int get videoViews => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$ChannelVideoCopyWith<_ChannelVideo> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,18 +1,36 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import '../extensions/helpers_extension.dart';
/// Encapsulates a valid YouTube user name.
class Username {
/// User name as string.
final String value;
part 'username.freezed.dart';
/// Encapsulates a valid YouTube user name.
@freezed
class Username with _$Username {
/// Initializes an instance of [Username].
Username(String urlOrUsername) : value = parseUsername(urlOrUsername) ?? '' {
if (value.isEmpty) {
factory Username(String urlOrUsername) {
final username = parseUsername(urlOrUsername);
if (username == null) {
throw ArgumentError.value(
urlOrUsername, 'urlOrUsername', 'Invalid username');
}
return Username._(username);
}
/// Converts [obj] to a [Username] by calling .toString on that object.
/// If it is already a [Username], [obj] is returned
factory Username.fromString(dynamic obj) {
if (obj is Username) {
return obj;
}
return Username(obj.toString());
}
const factory Username._(
/// User name as string.
final String value,
) = _Username;
/// Returns true if the given username is a valid username.
static bool validateUsername(String name) {
if (name.isNullOrWhiteSpace) {
@ -44,13 +62,4 @@ class Username {
}
return null;
}
/// Converts [obj] to a [Username] by calling .toString on that object.
/// If it is already a [Username], [obj] is returned
factory Username.fromString(dynamic obj) {
if (obj is Username) {
return obj;
}
return Username(obj.toString());
}
}

View File

@ -0,0 +1,141 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'username.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$UsernameTearOff {
const _$UsernameTearOff();
_Username _(String value) {
return _Username(
value,
);
}
}
/// @nodoc
const $Username = _$UsernameTearOff();
/// @nodoc
mixin _$Username {
/// User name as string.
String get value => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$UsernameCopyWith<Username> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UsernameCopyWith<$Res> {
factory $UsernameCopyWith(Username value, $Res Function(Username) then) =
_$UsernameCopyWithImpl<$Res>;
$Res call({String value});
}
/// @nodoc
class _$UsernameCopyWithImpl<$Res> implements $UsernameCopyWith<$Res> {
_$UsernameCopyWithImpl(this._value, this._then);
final Username _value;
// ignore: unused_field
final $Res Function(Username) _then;
@override
$Res call({
Object? value = freezed,
}) {
return _then(_value.copyWith(
value: value == freezed
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
abstract class _$UsernameCopyWith<$Res> implements $UsernameCopyWith<$Res> {
factory _$UsernameCopyWith(_Username value, $Res Function(_Username) then) =
__$UsernameCopyWithImpl<$Res>;
@override
$Res call({String value});
}
/// @nodoc
class __$UsernameCopyWithImpl<$Res> extends _$UsernameCopyWithImpl<$Res>
implements _$UsernameCopyWith<$Res> {
__$UsernameCopyWithImpl(_Username _value, $Res Function(_Username) _then)
: super(_value, (v) => _then(v as _Username));
@override
_Username get _value => super._value as _Username;
@override
$Res call({
Object? value = freezed,
}) {
return _then(_Username(
value == freezed
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$_Username implements _Username {
const _$_Username(this.value);
@override
/// User name as string.
final String value;
@override
String toString() {
return 'Username._(value: $value)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _Username &&
(identical(other.value, value) ||
const DeepCollectionEquality().equals(other.value, value)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(value);
@JsonKey(ignore: true)
@override
_$UsernameCopyWith<_Username> get copyWith =>
__$UsernameCopyWithImpl<_Username>(this, _$identity);
}
abstract class _Username implements Username {
const factory _Username(String value) = _$_Username;
@override
/// User name as string.
String get value => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$UsernameCopyWith<_Username> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,18 +1,22 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'engagement.freezed.dart';
/// User activity statistics.
class Engagement extends Equatable {
/// View count.
final int viewCount;
@freezed
class Engagement with _$Engagement {
const Engagement._();
/// Like count.
final int? likeCount;
const factory Engagement(
/// View count.
int viewCount,
/// Dislike count.
final int? dislikeCount;
/// Like count.
int? likeCount,
/// Initializes an instance of [Engagement]
const Engagement(this.viewCount, this.likeCount, this.dislikeCount);
/// Dislike count.
int? dislikeCount,
) = _Engagement;
/// Average user rating in stars (1 star to 5 stars).
/// Returns -1 if likeCount or dislikeCount is null.
@ -25,11 +29,4 @@ class Engagement extends Equatable {
}
return 1 + 4.0 * likeCount! / (likeCount! + dislikeCount!);
}
@override
String toString() =>
'$viewCount views, $likeCount likes, $dislikeCount dislikes';
@override
List<Object?> get props => [viewCount, likeCount, dislikeCount];
}

View File

@ -0,0 +1,201 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'engagement.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$EngagementTearOff {
const _$EngagementTearOff();
_Engagement call(int viewCount, int? likeCount, int? dislikeCount) {
return _Engagement(
viewCount,
likeCount,
dislikeCount,
);
}
}
/// @nodoc
const $Engagement = _$EngagementTearOff();
/// @nodoc
mixin _$Engagement {
/// View count.
int get viewCount => throw _privateConstructorUsedError;
/// Like count.
int? get likeCount => throw _privateConstructorUsedError;
/// Dislike count.
int? get dislikeCount => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$EngagementCopyWith<Engagement> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $EngagementCopyWith<$Res> {
factory $EngagementCopyWith(
Engagement value, $Res Function(Engagement) then) =
_$EngagementCopyWithImpl<$Res>;
$Res call({int viewCount, int? likeCount, int? dislikeCount});
}
/// @nodoc
class _$EngagementCopyWithImpl<$Res> implements $EngagementCopyWith<$Res> {
_$EngagementCopyWithImpl(this._value, this._then);
final Engagement _value;
// ignore: unused_field
final $Res Function(Engagement) _then;
@override
$Res call({
Object? viewCount = freezed,
Object? likeCount = freezed,
Object? dislikeCount = freezed,
}) {
return _then(_value.copyWith(
viewCount: viewCount == freezed
? _value.viewCount
: viewCount // ignore: cast_nullable_to_non_nullable
as int,
likeCount: likeCount == freezed
? _value.likeCount
: likeCount // ignore: cast_nullable_to_non_nullable
as int?,
dislikeCount: dislikeCount == freezed
? _value.dislikeCount
: dislikeCount // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}
/// @nodoc
abstract class _$EngagementCopyWith<$Res> implements $EngagementCopyWith<$Res> {
factory _$EngagementCopyWith(
_Engagement value, $Res Function(_Engagement) then) =
__$EngagementCopyWithImpl<$Res>;
@override
$Res call({int viewCount, int? likeCount, int? dislikeCount});
}
/// @nodoc
class __$EngagementCopyWithImpl<$Res> extends _$EngagementCopyWithImpl<$Res>
implements _$EngagementCopyWith<$Res> {
__$EngagementCopyWithImpl(
_Engagement _value, $Res Function(_Engagement) _then)
: super(_value, (v) => _then(v as _Engagement));
@override
_Engagement get _value => super._value as _Engagement;
@override
$Res call({
Object? viewCount = freezed,
Object? likeCount = freezed,
Object? dislikeCount = freezed,
}) {
return _then(_Engagement(
viewCount == freezed
? _value.viewCount
: viewCount // ignore: cast_nullable_to_non_nullable
as int,
likeCount == freezed
? _value.likeCount
: likeCount // ignore: cast_nullable_to_non_nullable
as int?,
dislikeCount == freezed
? _value.dislikeCount
: dislikeCount // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}
/// @nodoc
class _$_Engagement extends _Engagement {
const _$_Engagement(this.viewCount, this.likeCount, this.dislikeCount)
: super._();
@override
/// View count.
final int viewCount;
@override
/// Like count.
final int? likeCount;
@override
/// Dislike count.
final int? dislikeCount;
@override
String toString() {
return 'Engagement(viewCount: $viewCount, likeCount: $likeCount, dislikeCount: $dislikeCount)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _Engagement &&
(identical(other.viewCount, viewCount) ||
const DeepCollectionEquality()
.equals(other.viewCount, viewCount)) &&
(identical(other.likeCount, likeCount) ||
const DeepCollectionEquality()
.equals(other.likeCount, likeCount)) &&
(identical(other.dislikeCount, dislikeCount) ||
const DeepCollectionEquality()
.equals(other.dislikeCount, dislikeCount)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(viewCount) ^
const DeepCollectionEquality().hash(likeCount) ^
const DeepCollectionEquality().hash(dislikeCount);
@JsonKey(ignore: true)
@override
_$EngagementCopyWith<_Engagement> get copyWith =>
__$EngagementCopyWithImpl<_Engagement>(this, _$identity);
}
abstract class _Engagement extends Engagement {
const factory _Engagement(int viewCount, int? likeCount, int? dislikeCount) =
_$_Engagement;
const _Engagement._() : super._();
@override
/// View count.
int get viewCount => throw _privateConstructorUsedError;
@override
/// Like count.
int? get likeCount => throw _privateConstructorUsedError;
@override
/// Dislike count.
int? get dislikeCount => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$EngagementCopyWith<_Engagement> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,19 +1,18 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'thumbnail.freezed.dart';
/// Represent a channel thumbnail
class Thumbnail with EquatableMixin {
/// Image url.
final Uri url;
@freezed
class Thumbnail with _$Thumbnail {
const factory Thumbnail(
/// Image url.
Uri url,
/// Image height.
final int height;
/// Image height.
int height,
/// Image width.
final int width;
/// Initialize an instance of [Thumbnail].
Thumbnail(this.url, this.height, this.width);
@override
List<Object> get props => [url, height, width];
/// Image width.
int width,
) = _Thumbnail;
}

View File

@ -0,0 +1,193 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'thumbnail.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$ThumbnailTearOff {
const _$ThumbnailTearOff();
_Thumbnail call(Uri url, int height, int width) {
return _Thumbnail(
url,
height,
width,
);
}
}
/// @nodoc
const $Thumbnail = _$ThumbnailTearOff();
/// @nodoc
mixin _$Thumbnail {
/// Image url.
Uri get url => throw _privateConstructorUsedError;
/// Image height.
int get height => throw _privateConstructorUsedError;
/// Image width.
int get width => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ThumbnailCopyWith<Thumbnail> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ThumbnailCopyWith<$Res> {
factory $ThumbnailCopyWith(Thumbnail value, $Res Function(Thumbnail) then) =
_$ThumbnailCopyWithImpl<$Res>;
$Res call({Uri url, int height, int width});
}
/// @nodoc
class _$ThumbnailCopyWithImpl<$Res> implements $ThumbnailCopyWith<$Res> {
_$ThumbnailCopyWithImpl(this._value, this._then);
final Thumbnail _value;
// ignore: unused_field
final $Res Function(Thumbnail) _then;
@override
$Res call({
Object? url = freezed,
Object? height = freezed,
Object? width = freezed,
}) {
return _then(_value.copyWith(
url: url == freezed
? _value.url
: url // ignore: cast_nullable_to_non_nullable
as Uri,
height: height == freezed
? _value.height
: height // ignore: cast_nullable_to_non_nullable
as int,
width: width == freezed
? _value.width
: width // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
abstract class _$ThumbnailCopyWith<$Res> implements $ThumbnailCopyWith<$Res> {
factory _$ThumbnailCopyWith(
_Thumbnail value, $Res Function(_Thumbnail) then) =
__$ThumbnailCopyWithImpl<$Res>;
@override
$Res call({Uri url, int height, int width});
}
/// @nodoc
class __$ThumbnailCopyWithImpl<$Res> extends _$ThumbnailCopyWithImpl<$Res>
implements _$ThumbnailCopyWith<$Res> {
__$ThumbnailCopyWithImpl(_Thumbnail _value, $Res Function(_Thumbnail) _then)
: super(_value, (v) => _then(v as _Thumbnail));
@override
_Thumbnail get _value => super._value as _Thumbnail;
@override
$Res call({
Object? url = freezed,
Object? height = freezed,
Object? width = freezed,
}) {
return _then(_Thumbnail(
url == freezed
? _value.url
: url // ignore: cast_nullable_to_non_nullable
as Uri,
height == freezed
? _value.height
: height // ignore: cast_nullable_to_non_nullable
as int,
width == freezed
? _value.width
: width // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
class _$_Thumbnail implements _Thumbnail {
const _$_Thumbnail(this.url, this.height, this.width);
@override
/// Image url.
final Uri url;
@override
/// Image height.
final int height;
@override
/// Image width.
final int width;
@override
String toString() {
return 'Thumbnail(url: $url, height: $height, width: $width)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _Thumbnail &&
(identical(other.url, url) ||
const DeepCollectionEquality().equals(other.url, url)) &&
(identical(other.height, height) ||
const DeepCollectionEquality().equals(other.height, height)) &&
(identical(other.width, width) ||
const DeepCollectionEquality().equals(other.width, width)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(url) ^
const DeepCollectionEquality().hash(height) ^
const DeepCollectionEquality().hash(width);
@JsonKey(ignore: true)
@override
_$ThumbnailCopyWith<_Thumbnail> get copyWith =>
__$ThumbnailCopyWithImpl<_Thumbnail>(this, _$identity);
}
abstract class _Thumbnail implements Thumbnail {
const factory _Thumbnail(Uri url, int height, int width) = _$_Thumbnail;
@override
/// Image url.
Uri get url => throw _privateConstructorUsedError;
@override
/// Image height.
int get height => throw _privateConstructorUsedError;
@override
/// Image width.
int get width => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$ThumbnailCopyWith<_Thumbnail> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,12 +1,17 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'thumbnail_set.freezed.dart';
/// Set of thumbnails for a video.
class ThumbnailSet extends Equatable {
/// Video id.
final String videoId;
@freezed
class ThumbnailSet with _$ThumbnailSet {
/// Initializes an instance of [ThumbnailSet]
const ThumbnailSet(this.videoId);
const factory ThumbnailSet(
/// Video id.
String videoId) = _ThumbnailSet;
const ThumbnailSet._();
/// Low resolution thumbnail URL.
String get lowResUrl => 'https://img.youtube.com/vi/$videoId/default.jpg';

View File

@ -0,0 +1,146 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'thumbnail_set.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$ThumbnailSetTearOff {
const _$ThumbnailSetTearOff();
_ThumbnailSet call(String videoId) {
return _ThumbnailSet(
videoId,
);
}
}
/// @nodoc
const $ThumbnailSet = _$ThumbnailSetTearOff();
/// @nodoc
mixin _$ThumbnailSet {
/// Video id.
String get videoId => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ThumbnailSetCopyWith<ThumbnailSet> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ThumbnailSetCopyWith<$Res> {
factory $ThumbnailSetCopyWith(
ThumbnailSet value, $Res Function(ThumbnailSet) then) =
_$ThumbnailSetCopyWithImpl<$Res>;
$Res call({String videoId});
}
/// @nodoc
class _$ThumbnailSetCopyWithImpl<$Res> implements $ThumbnailSetCopyWith<$Res> {
_$ThumbnailSetCopyWithImpl(this._value, this._then);
final ThumbnailSet _value;
// ignore: unused_field
final $Res Function(ThumbnailSet) _then;
@override
$Res call({
Object? videoId = freezed,
}) {
return _then(_value.copyWith(
videoId: videoId == freezed
? _value.videoId
: videoId // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
abstract class _$ThumbnailSetCopyWith<$Res>
implements $ThumbnailSetCopyWith<$Res> {
factory _$ThumbnailSetCopyWith(
_ThumbnailSet value, $Res Function(_ThumbnailSet) then) =
__$ThumbnailSetCopyWithImpl<$Res>;
@override
$Res call({String videoId});
}
/// @nodoc
class __$ThumbnailSetCopyWithImpl<$Res> extends _$ThumbnailSetCopyWithImpl<$Res>
implements _$ThumbnailSetCopyWith<$Res> {
__$ThumbnailSetCopyWithImpl(
_ThumbnailSet _value, $Res Function(_ThumbnailSet) _then)
: super(_value, (v) => _then(v as _ThumbnailSet));
@override
_ThumbnailSet get _value => super._value as _ThumbnailSet;
@override
$Res call({
Object? videoId = freezed,
}) {
return _then(_ThumbnailSet(
videoId == freezed
? _value.videoId
: videoId // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$_ThumbnailSet extends _ThumbnailSet {
const _$_ThumbnailSet(this.videoId) : super._();
@override
/// Video id.
final String videoId;
@override
String toString() {
return 'ThumbnailSet(videoId: $videoId)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _ThumbnailSet &&
(identical(other.videoId, videoId) ||
const DeepCollectionEquality().equals(other.videoId, videoId)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(videoId);
@JsonKey(ignore: true)
@override
_$ThumbnailSetCopyWith<_ThumbnailSet> get copyWith =>
__$ThumbnailSetCopyWithImpl<_ThumbnailSet>(this, _$identity);
}
abstract class _ThumbnailSet extends ThumbnailSet {
const factory _ThumbnailSet(String videoId) = _$_ThumbnailSet;
const _ThumbnailSet._() : super._();
@override
/// Video id.
String get videoId => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$ThumbnailSetCopyWith<_ThumbnailSet> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,40 +1,39 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../common/common.dart';
import 'playlist_id.dart';
part 'playlist.freezed.dart';
/// YouTube playlist metadata.
class Playlist with EquatableMixin {
/// Playlist ID.
final PlaylistId id;
@freezed
class Playlist with _$Playlist {
/// Initializes an instance of [Playlist].
const factory Playlist(
/// Playlist ID.
PlaylistId id,
/// Playlist title.
String title,
/// Playlist author.
/// Can be null if it's a system playlist (e.g. Video Mix, Topics, etc.).
String author,
/// Playlist description.
String description,
/// Available thumbnails for this playlist.
/// Can be null if the playlist is empty.
ThumbnailSet thumbnails,
/// Engagement statistics.
Engagement engagement,
) = _Playlist;
const Playlist._();
/// Playlist URL.
String get url => 'https://www.youtube.com/playlist?list=$id';
/// Playlist title.
final String title;
/// Playlist author.
/// Can be null if it's a system playlist (e.g. Video Mix, Topics, etc.).
final String author;
/// Playlist description.
final String description;
/// Available thumbnails for this playlist.
/// Can be null if the playlist is empty.
final ThumbnailSet thumbnails;
/// Engagement statistics.
final Engagement engagement;
/// Initializes an instance of [Playlist].
Playlist(this.id, this.title, this.author, this.description, this.thumbnails,
this.engagement);
@override
String toString() => 'Playlist ($title)';
@override
List<Object> get props => [id];
}

View File

@ -0,0 +1,330 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'playlist.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$PlaylistTearOff {
const _$PlaylistTearOff();
_Playlist call(PlaylistId id, String title, String author, String description,
ThumbnailSet thumbnails, Engagement engagement) {
return _Playlist(
id,
title,
author,
description,
thumbnails,
engagement,
);
}
}
/// @nodoc
const $Playlist = _$PlaylistTearOff();
/// @nodoc
mixin _$Playlist {
/// Playlist ID.
PlaylistId get id => throw _privateConstructorUsedError;
/// Playlist title.
String get title => throw _privateConstructorUsedError;
/// Playlist author.
/// Can be null if it's a system playlist (e.g. Video Mix, Topics, etc.).
String get author => throw _privateConstructorUsedError;
/// Playlist description.
String get description => throw _privateConstructorUsedError;
/// Available thumbnails for this playlist.
/// Can be null if the playlist is empty.
ThumbnailSet get thumbnails => throw _privateConstructorUsedError;
/// Engagement statistics.
Engagement get engagement => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$PlaylistCopyWith<Playlist> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $PlaylistCopyWith<$Res> {
factory $PlaylistCopyWith(Playlist value, $Res Function(Playlist) then) =
_$PlaylistCopyWithImpl<$Res>;
$Res call(
{PlaylistId id,
String title,
String author,
String description,
ThumbnailSet thumbnails,
Engagement engagement});
$PlaylistIdCopyWith<$Res> get id;
$ThumbnailSetCopyWith<$Res> get thumbnails;
$EngagementCopyWith<$Res> get engagement;
}
/// @nodoc
class _$PlaylistCopyWithImpl<$Res> implements $PlaylistCopyWith<$Res> {
_$PlaylistCopyWithImpl(this._value, this._then);
final Playlist _value;
// ignore: unused_field
final $Res Function(Playlist) _then;
@override
$Res call({
Object? id = freezed,
Object? title = freezed,
Object? author = freezed,
Object? description = freezed,
Object? thumbnails = freezed,
Object? engagement = freezed,
}) {
return _then(_value.copyWith(
id: id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as PlaylistId,
title: title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
author: author == freezed
? _value.author
: author // ignore: cast_nullable_to_non_nullable
as String,
description: description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
thumbnails: thumbnails == freezed
? _value.thumbnails
: thumbnails // ignore: cast_nullable_to_non_nullable
as ThumbnailSet,
engagement: engagement == freezed
? _value.engagement
: engagement // ignore: cast_nullable_to_non_nullable
as Engagement,
));
}
@override
$PlaylistIdCopyWith<$Res> get id {
return $PlaylistIdCopyWith<$Res>(_value.id, (value) {
return _then(_value.copyWith(id: value));
});
}
@override
$ThumbnailSetCopyWith<$Res> get thumbnails {
return $ThumbnailSetCopyWith<$Res>(_value.thumbnails, (value) {
return _then(_value.copyWith(thumbnails: value));
});
}
@override
$EngagementCopyWith<$Res> get engagement {
return $EngagementCopyWith<$Res>(_value.engagement, (value) {
return _then(_value.copyWith(engagement: value));
});
}
}
/// @nodoc
abstract class _$PlaylistCopyWith<$Res> implements $PlaylistCopyWith<$Res> {
factory _$PlaylistCopyWith(_Playlist value, $Res Function(_Playlist) then) =
__$PlaylistCopyWithImpl<$Res>;
@override
$Res call(
{PlaylistId id,
String title,
String author,
String description,
ThumbnailSet thumbnails,
Engagement engagement});
@override
$PlaylistIdCopyWith<$Res> get id;
@override
$ThumbnailSetCopyWith<$Res> get thumbnails;
@override
$EngagementCopyWith<$Res> get engagement;
}
/// @nodoc
class __$PlaylistCopyWithImpl<$Res> extends _$PlaylistCopyWithImpl<$Res>
implements _$PlaylistCopyWith<$Res> {
__$PlaylistCopyWithImpl(_Playlist _value, $Res Function(_Playlist) _then)
: super(_value, (v) => _then(v as _Playlist));
@override
_Playlist get _value => super._value as _Playlist;
@override
$Res call({
Object? id = freezed,
Object? title = freezed,
Object? author = freezed,
Object? description = freezed,
Object? thumbnails = freezed,
Object? engagement = freezed,
}) {
return _then(_Playlist(
id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as PlaylistId,
title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
author == freezed
? _value.author
: author // ignore: cast_nullable_to_non_nullable
as String,
description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
thumbnails == freezed
? _value.thumbnails
: thumbnails // ignore: cast_nullable_to_non_nullable
as ThumbnailSet,
engagement == freezed
? _value.engagement
: engagement // ignore: cast_nullable_to_non_nullable
as Engagement,
));
}
}
/// @nodoc
class _$_Playlist extends _Playlist {
const _$_Playlist(this.id, this.title, this.author, this.description,
this.thumbnails, this.engagement)
: super._();
@override
/// Playlist ID.
final PlaylistId id;
@override
/// Playlist title.
final String title;
@override
/// Playlist author.
/// Can be null if it's a system playlist (e.g. Video Mix, Topics, etc.).
final String author;
@override
/// Playlist description.
final String description;
@override
/// Available thumbnails for this playlist.
/// Can be null if the playlist is empty.
final ThumbnailSet thumbnails;
@override
/// Engagement statistics.
final Engagement engagement;
@override
String toString() {
return 'Playlist(id: $id, title: $title, author: $author, description: $description, thumbnails: $thumbnails, engagement: $engagement)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _Playlist &&
(identical(other.id, id) ||
const DeepCollectionEquality().equals(other.id, id)) &&
(identical(other.title, title) ||
const DeepCollectionEquality().equals(other.title, title)) &&
(identical(other.author, author) ||
const DeepCollectionEquality().equals(other.author, author)) &&
(identical(other.description, description) ||
const DeepCollectionEquality()
.equals(other.description, description)) &&
(identical(other.thumbnails, thumbnails) ||
const DeepCollectionEquality()
.equals(other.thumbnails, thumbnails)) &&
(identical(other.engagement, engagement) ||
const DeepCollectionEquality()
.equals(other.engagement, engagement)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(id) ^
const DeepCollectionEquality().hash(title) ^
const DeepCollectionEquality().hash(author) ^
const DeepCollectionEquality().hash(description) ^
const DeepCollectionEquality().hash(thumbnails) ^
const DeepCollectionEquality().hash(engagement);
@JsonKey(ignore: true)
@override
_$PlaylistCopyWith<_Playlist> get copyWith =>
__$PlaylistCopyWithImpl<_Playlist>(this, _$identity);
}
abstract class _Playlist extends Playlist {
const factory _Playlist(
PlaylistId id,
String title,
String author,
String description,
ThumbnailSet thumbnails,
Engagement engagement) = _$_Playlist;
const _Playlist._() : super._();
@override
/// Playlist ID.
PlaylistId get id => throw _privateConstructorUsedError;
@override
/// Playlist title.
String get title => throw _privateConstructorUsedError;
@override
/// Playlist author.
/// Can be null if it's a system playlist (e.g. Video Mix, Topics, etc.).
String get author => throw _privateConstructorUsedError;
@override
/// Playlist description.
String get description => throw _privateConstructorUsedError;
@override
/// Available thumbnails for this playlist.
/// Can be null if the playlist is empty.
ThumbnailSet get thumbnails => throw _privateConstructorUsedError;
@override
/// Engagement statistics.
Engagement get engagement => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$PlaylistCopyWith<_Playlist> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,9 +1,12 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../extensions/helpers_extension.dart';
part 'playlist_id.freezed.dart';
/// Encapsulates a valid YouTube playlist ID.
class PlaylistId with EquatableMixin {
@freezed
class PlaylistId with _$PlaylistId {
static final _regMatchExp =
RegExp(r'youtube\..+?/playlist.*?list=(.*?)(?:&|/|$)');
static final _compositeMatchExp =
@ -13,14 +16,29 @@ class PlaylistId with EquatableMixin {
static final _embedCompositeMatchExp =
RegExp(r'youtube\..+?/embed/.*?/.*?list=(.*?)(?:&|/|$)');
/// The playlist id as string.
final String value;
const PlaylistId._();
const factory PlaylistId._internal(
/// The playlist id as string.
String value) = _PlaylistId;
/// Initializes an instance of [PlaylistId]
PlaylistId(String idOrUrl) : value = parsePlaylistId(idOrUrl) ?? '' {
if (value.isEmpty) {
factory PlaylistId(String idOrUrl) {
final id = parsePlaylistId(idOrUrl);
if (id == null) {
throw ArgumentError.value(idOrUrl, 'idOrUrl', 'Invalid url');
}
return PlaylistId._internal(id);
}
/// Converts [obj] to a [PlaylistId] by calling .toString on that object.
/// If it is already a [PlaylistId], [obj] is returned
factory PlaylistId.fromString(dynamic obj) {
if (obj is PlaylistId) {
return obj;
}
return PlaylistId(obj.toString());
}
/// Returns true if the given [playlistId] is valid.
@ -97,16 +115,4 @@ class PlaylistId with EquatableMixin {
@override
String toString() => value;
/// Converts [obj] to a [PlaylistId] by calling .toString on that object.
/// If it is already a [PlaylistId], [obj] is returned
factory PlaylistId.fromString(dynamic obj) {
if (obj is PlaylistId) {
return obj;
}
return PlaylistId(obj.toString());
}
@override
List<Object> get props => [value];
}

View File

@ -0,0 +1,140 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'playlist_id.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$PlaylistIdTearOff {
const _$PlaylistIdTearOff();
_PlaylistId _internal(String value) {
return _PlaylistId(
value,
);
}
}
/// @nodoc
const $PlaylistId = _$PlaylistIdTearOff();
/// @nodoc
mixin _$PlaylistId {
/// The playlist id as string.
String get value => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$PlaylistIdCopyWith<PlaylistId> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $PlaylistIdCopyWith<$Res> {
factory $PlaylistIdCopyWith(
PlaylistId value, $Res Function(PlaylistId) then) =
_$PlaylistIdCopyWithImpl<$Res>;
$Res call({String value});
}
/// @nodoc
class _$PlaylistIdCopyWithImpl<$Res> implements $PlaylistIdCopyWith<$Res> {
_$PlaylistIdCopyWithImpl(this._value, this._then);
final PlaylistId _value;
// ignore: unused_field
final $Res Function(PlaylistId) _then;
@override
$Res call({
Object? value = freezed,
}) {
return _then(_value.copyWith(
value: value == freezed
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
abstract class _$PlaylistIdCopyWith<$Res> implements $PlaylistIdCopyWith<$Res> {
factory _$PlaylistIdCopyWith(
_PlaylistId value, $Res Function(_PlaylistId) then) =
__$PlaylistIdCopyWithImpl<$Res>;
@override
$Res call({String value});
}
/// @nodoc
class __$PlaylistIdCopyWithImpl<$Res> extends _$PlaylistIdCopyWithImpl<$Res>
implements _$PlaylistIdCopyWith<$Res> {
__$PlaylistIdCopyWithImpl(
_PlaylistId _value, $Res Function(_PlaylistId) _then)
: super(_value, (v) => _then(v as _PlaylistId));
@override
_PlaylistId get _value => super._value as _PlaylistId;
@override
$Res call({
Object? value = freezed,
}) {
return _then(_PlaylistId(
value == freezed
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$_PlaylistId extends _PlaylistId {
const _$_PlaylistId(this.value) : super._();
@override
/// The playlist id as string.
final String value;
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _PlaylistId &&
(identical(other.value, value) ||
const DeepCollectionEquality().equals(other.value, value)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(value);
@JsonKey(ignore: true)
@override
_$PlaylistIdCopyWith<_PlaylistId> get copyWith =>
__$PlaylistIdCopyWithImpl<_PlaylistId>(this, _$identity);
}
abstract class _PlaylistId extends PlaylistId {
const factory _PlaylistId(String value) = _$_PlaylistId;
const _PlaylistId._() : super._();
@override
/// The playlist id as string.
String get value => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$PlaylistIdCopyWith<_PlaylistId> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,5 +1,2 @@
/// This i can either be a [SearchVideo] or [SearchPlaylist]
abstract class BaseSearchContent {
///
const BaseSearchContent();
}
mixin BaseSearchContent {}

View File

@ -1,21 +1,18 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../videos/video_id.dart';
part 'related_query.freezed.dart';
///
class RelatedQuery with EquatableMixin {
/// Query related to a search query.
final String query;
/// Video related to a search query.
final VideoId videoId;
@freezed
class RelatedQuery with _$RelatedQuery {
/// Initialize a [RelatedQuery] instance.
RelatedQuery(this.query, this.videoId);
const factory RelatedQuery(
@override
String toString() => 'RelatedQuery($videoId): $query';
/// Query related to a search query.
String query,
@override
List<Object> get props => [query, videoId];
/// Video related to a search query.
VideoId videoId) = _RelatedQuery;
}

View File

@ -0,0 +1,183 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'related_query.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$RelatedQueryTearOff {
const _$RelatedQueryTearOff();
_RelatedQuery call(String query, VideoId videoId) {
return _RelatedQuery(
query,
videoId,
);
}
}
/// @nodoc
const $RelatedQuery = _$RelatedQueryTearOff();
/// @nodoc
mixin _$RelatedQuery {
/// Query related to a search query.
String get query => throw _privateConstructorUsedError;
/// Video related to a search query.
VideoId get videoId => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$RelatedQueryCopyWith<RelatedQuery> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $RelatedQueryCopyWith<$Res> {
factory $RelatedQueryCopyWith(
RelatedQuery value, $Res Function(RelatedQuery) then) =
_$RelatedQueryCopyWithImpl<$Res>;
$Res call({String query, VideoId videoId});
$VideoIdCopyWith<$Res> get videoId;
}
/// @nodoc
class _$RelatedQueryCopyWithImpl<$Res> implements $RelatedQueryCopyWith<$Res> {
_$RelatedQueryCopyWithImpl(this._value, this._then);
final RelatedQuery _value;
// ignore: unused_field
final $Res Function(RelatedQuery) _then;
@override
$Res call({
Object? query = freezed,
Object? videoId = freezed,
}) {
return _then(_value.copyWith(
query: query == freezed
? _value.query
: query // ignore: cast_nullable_to_non_nullable
as String,
videoId: videoId == freezed
? _value.videoId
: videoId // ignore: cast_nullable_to_non_nullable
as VideoId,
));
}
@override
$VideoIdCopyWith<$Res> get videoId {
return $VideoIdCopyWith<$Res>(_value.videoId, (value) {
return _then(_value.copyWith(videoId: value));
});
}
}
/// @nodoc
abstract class _$RelatedQueryCopyWith<$Res>
implements $RelatedQueryCopyWith<$Res> {
factory _$RelatedQueryCopyWith(
_RelatedQuery value, $Res Function(_RelatedQuery) then) =
__$RelatedQueryCopyWithImpl<$Res>;
@override
$Res call({String query, VideoId videoId});
@override
$VideoIdCopyWith<$Res> get videoId;
}
/// @nodoc
class __$RelatedQueryCopyWithImpl<$Res> extends _$RelatedQueryCopyWithImpl<$Res>
implements _$RelatedQueryCopyWith<$Res> {
__$RelatedQueryCopyWithImpl(
_RelatedQuery _value, $Res Function(_RelatedQuery) _then)
: super(_value, (v) => _then(v as _RelatedQuery));
@override
_RelatedQuery get _value => super._value as _RelatedQuery;
@override
$Res call({
Object? query = freezed,
Object? videoId = freezed,
}) {
return _then(_RelatedQuery(
query == freezed
? _value.query
: query // ignore: cast_nullable_to_non_nullable
as String,
videoId == freezed
? _value.videoId
: videoId // ignore: cast_nullable_to_non_nullable
as VideoId,
));
}
}
/// @nodoc
class _$_RelatedQuery implements _RelatedQuery {
const _$_RelatedQuery(this.query, this.videoId);
@override
/// Query related to a search query.
final String query;
@override
/// Video related to a search query.
final VideoId videoId;
@override
String toString() {
return 'RelatedQuery(query: $query, videoId: $videoId)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _RelatedQuery &&
(identical(other.query, query) ||
const DeepCollectionEquality().equals(other.query, query)) &&
(identical(other.videoId, videoId) ||
const DeepCollectionEquality().equals(other.videoId, videoId)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(query) ^
const DeepCollectionEquality().hash(videoId);
@JsonKey(ignore: true)
@override
_$RelatedQueryCopyWith<_RelatedQuery> get copyWith =>
__$RelatedQueryCopyWithImpl<_RelatedQuery>(this, _$identity);
}
abstract class _RelatedQuery implements RelatedQuery {
const factory _RelatedQuery(String query, VideoId videoId) = _$_RelatedQuery;
@override
/// Query related to a search query.
String get query => throw _privateConstructorUsedError;
@override
/// Video related to a search query.
VideoId get videoId => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$RelatedQueryCopyWith<_RelatedQuery> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,29 +1,28 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../channels/channel_id.dart';
import 'base_search_content.dart';
part 'search_channel.freezed.dart';
/// Metadata related to a search query result (channel)
class SearchChannel extends BaseSearchContent with EquatableMixin {
/// Channel id.
final ChannelId id;
/// Channel name.
final String name;
/// Description snippet.
/// Can be empty.
final String description;
/// Channel uploaded videos.
final int videoCount;
@freezed
class SearchChannel with _$SearchChannel, BaseSearchContent {
/// Initialize a [SearchChannel] instance.
SearchChannel(this.id, this.name, this.description, this.videoCount);
@With(BaseSearchContent)
const factory SearchChannel(
@override
String toString() => '(Channel) $name ($id)';
/// Channel id.
ChannelId id,
@override
List<Object?> get props => [id, name, description, videoCount];
/// Channel name.
String name,
/// Description snippet.
/// Can be empty.
String description,
/// Channel uploaded videos.
int videoCount) = _SearchChannel;
}

View File

@ -0,0 +1,244 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'search_channel.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$SearchChannelTearOff {
const _$SearchChannelTearOff();
_SearchChannel call(
ChannelId id, String name, String description, int videoCount) {
return _SearchChannel(
id,
name,
description,
videoCount,
);
}
}
/// @nodoc
const $SearchChannel = _$SearchChannelTearOff();
/// @nodoc
mixin _$SearchChannel {
/// Channel id.
ChannelId get id => throw _privateConstructorUsedError;
/// Channel name.
String get name => throw _privateConstructorUsedError;
/// Description snippet.
/// Can be empty.
String get description => throw _privateConstructorUsedError;
/// Channel uploaded videos.
int get videoCount => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SearchChannelCopyWith<SearchChannel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SearchChannelCopyWith<$Res> {
factory $SearchChannelCopyWith(
SearchChannel value, $Res Function(SearchChannel) then) =
_$SearchChannelCopyWithImpl<$Res>;
$Res call({ChannelId id, String name, String description, int videoCount});
$ChannelIdCopyWith<$Res> get id;
}
/// @nodoc
class _$SearchChannelCopyWithImpl<$Res>
implements $SearchChannelCopyWith<$Res> {
_$SearchChannelCopyWithImpl(this._value, this._then);
final SearchChannel _value;
// ignore: unused_field
final $Res Function(SearchChannel) _then;
@override
$Res call({
Object? id = freezed,
Object? name = freezed,
Object? description = freezed,
Object? videoCount = freezed,
}) {
return _then(_value.copyWith(
id: id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as ChannelId,
name: name == freezed
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
videoCount: videoCount == freezed
? _value.videoCount
: videoCount // ignore: cast_nullable_to_non_nullable
as int,
));
}
@override
$ChannelIdCopyWith<$Res> get id {
return $ChannelIdCopyWith<$Res>(_value.id, (value) {
return _then(_value.copyWith(id: value));
});
}
}
/// @nodoc
abstract class _$SearchChannelCopyWith<$Res>
implements $SearchChannelCopyWith<$Res> {
factory _$SearchChannelCopyWith(
_SearchChannel value, $Res Function(_SearchChannel) then) =
__$SearchChannelCopyWithImpl<$Res>;
@override
$Res call({ChannelId id, String name, String description, int videoCount});
@override
$ChannelIdCopyWith<$Res> get id;
}
/// @nodoc
class __$SearchChannelCopyWithImpl<$Res>
extends _$SearchChannelCopyWithImpl<$Res>
implements _$SearchChannelCopyWith<$Res> {
__$SearchChannelCopyWithImpl(
_SearchChannel _value, $Res Function(_SearchChannel) _then)
: super(_value, (v) => _then(v as _SearchChannel));
@override
_SearchChannel get _value => super._value as _SearchChannel;
@override
$Res call({
Object? id = freezed,
Object? name = freezed,
Object? description = freezed,
Object? videoCount = freezed,
}) {
return _then(_SearchChannel(
id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as ChannelId,
name == freezed
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
videoCount == freezed
? _value.videoCount
: videoCount // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@With(BaseSearchContent)
class _$_SearchChannel with BaseSearchContent implements _SearchChannel {
const _$_SearchChannel(this.id, this.name, this.description, this.videoCount);
@override
/// Channel id.
final ChannelId id;
@override
/// Channel name.
final String name;
@override
/// Description snippet.
/// Can be empty.
final String description;
@override
/// Channel uploaded videos.
final int videoCount;
@override
String toString() {
return 'SearchChannel(id: $id, name: $name, description: $description, videoCount: $videoCount)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _SearchChannel &&
(identical(other.id, id) ||
const DeepCollectionEquality().equals(other.id, id)) &&
(identical(other.name, name) ||
const DeepCollectionEquality().equals(other.name, name)) &&
(identical(other.description, description) ||
const DeepCollectionEquality()
.equals(other.description, description)) &&
(identical(other.videoCount, videoCount) ||
const DeepCollectionEquality()
.equals(other.videoCount, videoCount)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(id) ^
const DeepCollectionEquality().hash(name) ^
const DeepCollectionEquality().hash(description) ^
const DeepCollectionEquality().hash(videoCount);
@JsonKey(ignore: true)
@override
_$SearchChannelCopyWith<_SearchChannel> get copyWith =>
__$SearchChannelCopyWithImpl<_SearchChannel>(this, _$identity);
}
abstract class _SearchChannel implements SearchChannel, BaseSearchContent {
const factory _SearchChannel(
ChannelId id, String name, String description, int videoCount) =
_$_SearchChannel;
@override
/// Channel id.
ChannelId get id => throw _privateConstructorUsedError;
@override
/// Channel name.
String get name => throw _privateConstructorUsedError;
@override
/// Description snippet.
/// Can be empty.
String get description => throw _privateConstructorUsedError;
@override
/// Channel uploaded videos.
int get videoCount => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$SearchChannelCopyWith<_SearchChannel> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,25 +1,23 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../playlists/playlist_id.dart';
import 'base_search_content.dart';
part 'search_playlist.freezed.dart';
/// Metadata related to a search query result (playlist)
class SearchPlaylist extends BaseSearchContent with EquatableMixin {
/// PlaylistId.
final PlaylistId playlistId;
@freezed
class SearchPlaylist with _$SearchPlaylist, BaseSearchContent {
/// Initialize a [SearchPlaylist] instance.
@With(BaseSearchContent)
const factory SearchPlaylist(
/// Playlist title.
final String playlistTitle;
/// PlaylistId.
PlaylistId playlistId,
/// Playlist video count, cannot be greater than 50.
final int playlistVideoCount;
/// Playlist title.
String playlistTitle,
/// Initialize an instance of [SearchPlaylist]
SearchPlaylist(this.playlistId, this.playlistTitle, this.playlistVideoCount);
@override
String toString() => '[Playlist] $playlistTitle ($playlistId)';
@override
List<Object> get props => [playlistId];
/// Playlist video count, cannot be greater than 50.
int playlistVideoCount) = _SearchChannel;
}

View File

@ -0,0 +1,220 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'search_playlist.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$SearchPlaylistTearOff {
const _$SearchPlaylistTearOff();
_SearchChannel call(
PlaylistId playlistId, String playlistTitle, int playlistVideoCount) {
return _SearchChannel(
playlistId,
playlistTitle,
playlistVideoCount,
);
}
}
/// @nodoc
const $SearchPlaylist = _$SearchPlaylistTearOff();
/// @nodoc
mixin _$SearchPlaylist {
/// PlaylistId.
PlaylistId get playlistId => throw _privateConstructorUsedError;
/// Playlist title.
String get playlistTitle => throw _privateConstructorUsedError;
/// Playlist video count, cannot be greater than 50.
int get playlistVideoCount => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SearchPlaylistCopyWith<SearchPlaylist> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SearchPlaylistCopyWith<$Res> {
factory $SearchPlaylistCopyWith(
SearchPlaylist value, $Res Function(SearchPlaylist) then) =
_$SearchPlaylistCopyWithImpl<$Res>;
$Res call(
{PlaylistId playlistId, String playlistTitle, int playlistVideoCount});
$PlaylistIdCopyWith<$Res> get playlistId;
}
/// @nodoc
class _$SearchPlaylistCopyWithImpl<$Res>
implements $SearchPlaylistCopyWith<$Res> {
_$SearchPlaylistCopyWithImpl(this._value, this._then);
final SearchPlaylist _value;
// ignore: unused_field
final $Res Function(SearchPlaylist) _then;
@override
$Res call({
Object? playlistId = freezed,
Object? playlistTitle = freezed,
Object? playlistVideoCount = freezed,
}) {
return _then(_value.copyWith(
playlistId: playlistId == freezed
? _value.playlistId
: playlistId // ignore: cast_nullable_to_non_nullable
as PlaylistId,
playlistTitle: playlistTitle == freezed
? _value.playlistTitle
: playlistTitle // ignore: cast_nullable_to_non_nullable
as String,
playlistVideoCount: playlistVideoCount == freezed
? _value.playlistVideoCount
: playlistVideoCount // ignore: cast_nullable_to_non_nullable
as int,
));
}
@override
$PlaylistIdCopyWith<$Res> get playlistId {
return $PlaylistIdCopyWith<$Res>(_value.playlistId, (value) {
return _then(_value.copyWith(playlistId: value));
});
}
}
/// @nodoc
abstract class _$SearchChannelCopyWith<$Res>
implements $SearchPlaylistCopyWith<$Res> {
factory _$SearchChannelCopyWith(
_SearchChannel value, $Res Function(_SearchChannel) then) =
__$SearchChannelCopyWithImpl<$Res>;
@override
$Res call(
{PlaylistId playlistId, String playlistTitle, int playlistVideoCount});
@override
$PlaylistIdCopyWith<$Res> get playlistId;
}
/// @nodoc
class __$SearchChannelCopyWithImpl<$Res>
extends _$SearchPlaylistCopyWithImpl<$Res>
implements _$SearchChannelCopyWith<$Res> {
__$SearchChannelCopyWithImpl(
_SearchChannel _value, $Res Function(_SearchChannel) _then)
: super(_value, (v) => _then(v as _SearchChannel));
@override
_SearchChannel get _value => super._value as _SearchChannel;
@override
$Res call({
Object? playlistId = freezed,
Object? playlistTitle = freezed,
Object? playlistVideoCount = freezed,
}) {
return _then(_SearchChannel(
playlistId == freezed
? _value.playlistId
: playlistId // ignore: cast_nullable_to_non_nullable
as PlaylistId,
playlistTitle == freezed
? _value.playlistTitle
: playlistTitle // ignore: cast_nullable_to_non_nullable
as String,
playlistVideoCount == freezed
? _value.playlistVideoCount
: playlistVideoCount // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@With(BaseSearchContent)
class _$_SearchChannel with BaseSearchContent implements _SearchChannel {
const _$_SearchChannel(
this.playlistId, this.playlistTitle, this.playlistVideoCount);
@override
/// PlaylistId.
final PlaylistId playlistId;
@override
/// Playlist title.
final String playlistTitle;
@override
/// Playlist video count, cannot be greater than 50.
final int playlistVideoCount;
@override
String toString() {
return 'SearchPlaylist(playlistId: $playlistId, playlistTitle: $playlistTitle, playlistVideoCount: $playlistVideoCount)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _SearchChannel &&
(identical(other.playlistId, playlistId) ||
const DeepCollectionEquality()
.equals(other.playlistId, playlistId)) &&
(identical(other.playlistTitle, playlistTitle) ||
const DeepCollectionEquality()
.equals(other.playlistTitle, playlistTitle)) &&
(identical(other.playlistVideoCount, playlistVideoCount) ||
const DeepCollectionEquality()
.equals(other.playlistVideoCount, playlistVideoCount)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(playlistId) ^
const DeepCollectionEquality().hash(playlistTitle) ^
const DeepCollectionEquality().hash(playlistVideoCount);
@JsonKey(ignore: true)
@override
_$SearchChannelCopyWith<_SearchChannel> get copyWith =>
__$SearchChannelCopyWithImpl<_SearchChannel>(this, _$identity);
}
abstract class _SearchChannel implements SearchPlaylist, BaseSearchContent {
const factory _SearchChannel(
PlaylistId playlistId, String playlistTitle, int playlistVideoCount) =
_$_SearchChannel;
@override
/// PlaylistId.
PlaylistId get playlistId => throw _privateConstructorUsedError;
@override
/// Playlist title.
String get playlistTitle => throw _privateConstructorUsedError;
@override
/// Playlist video count, cannot be greater than 50.
int get playlistVideoCount => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$SearchChannelCopyWith<_SearchChannel> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,52 +1,45 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import '../common/common.dart';
import '../videos/video_id.dart';
import 'base_search_content.dart';
part 'search_video.freezed.dart';
/// Metadata related to a search query result (video).
class SearchVideo extends BaseSearchContent {
/// Video ID.
final VideoId id;
/// Video title.
final String title;
/// Video author.
final String author;
/// Video description snippet. (Part of the full description if too long)
final String description;
/// Video duration as String, HH:MM:SS
final String duration;
/// Video View Count
final int viewCount;
/// Video thumbnail
final List<Thumbnail> thumbnails;
/// Video upload date - As string: 5 years ago.
final String? uploadDate;
/// True if this video is a live stream.
final bool isLive;
/// Channel id
final String channelId;
@freezed
class SearchVideo with _$SearchVideo, BaseSearchContent {
/// Initialize a [SearchVideo] instance.
const SearchVideo(
this.id,
this.title,
this.author,
this.description,
this.duration,
this.viewCount,
this.thumbnails,
this.uploadDate,
this.isLive, // ignore: avoid_positional_boolean_parameters
this.channelId);
@With(BaseSearchContent)
const factory SearchVideo(
/// Video ID.
VideoId id,
@override
String toString() => '(Video) $title ($id)';
/// Video title.
String title,
/// Video author.
String author,
/// Video description snippet. (Part of the full description if too long)
String description,
/// Video duration as String, HH:MM:SS
String duration,
/// Video View Count
int viewCount,
/// Video thumbnail
List<Thumbnail> thumbnails,
/// Video upload date - As string: 5 years ago.
String? uploadDate,
/// True if this video is a live stream.
bool isLive,
/// Channel id
String channelId,
) = _SearchVideo;
}

View File

@ -0,0 +1,440 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'search_video.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$SearchVideoTearOff {
const _$SearchVideoTearOff();
_SearchVideo call(
VideoId id,
String title,
String author,
String description,
String duration,
int viewCount,
List<Thumbnail> thumbnails,
String? uploadDate,
bool isLive,
String channelId) {
return _SearchVideo(
id,
title,
author,
description,
duration,
viewCount,
thumbnails,
uploadDate,
isLive,
channelId,
);
}
}
/// @nodoc
const $SearchVideo = _$SearchVideoTearOff();
/// @nodoc
mixin _$SearchVideo {
/// Video ID.
VideoId get id => throw _privateConstructorUsedError;
/// Video title.
String get title => throw _privateConstructorUsedError;
/// Video author.
String get author => throw _privateConstructorUsedError;
/// Video description snippet. (Part of the full description if too long)
String get description => throw _privateConstructorUsedError;
/// Video duration as String, HH:MM:SS
String get duration => throw _privateConstructorUsedError;
/// Video View Count
int get viewCount => throw _privateConstructorUsedError;
/// Video thumbnail
List<Thumbnail> get thumbnails => throw _privateConstructorUsedError;
/// Video upload date - As string: 5 years ago.
String? get uploadDate => throw _privateConstructorUsedError;
/// True if this video is a live stream.
bool get isLive => throw _privateConstructorUsedError;
/// Channel id
String get channelId => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SearchVideoCopyWith<SearchVideo> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SearchVideoCopyWith<$Res> {
factory $SearchVideoCopyWith(
SearchVideo value, $Res Function(SearchVideo) then) =
_$SearchVideoCopyWithImpl<$Res>;
$Res call(
{VideoId id,
String title,
String author,
String description,
String duration,
int viewCount,
List<Thumbnail> thumbnails,
String? uploadDate,
bool isLive,
String channelId});
$VideoIdCopyWith<$Res> get id;
}
/// @nodoc
class _$SearchVideoCopyWithImpl<$Res> implements $SearchVideoCopyWith<$Res> {
_$SearchVideoCopyWithImpl(this._value, this._then);
final SearchVideo _value;
// ignore: unused_field
final $Res Function(SearchVideo) _then;
@override
$Res call({
Object? id = freezed,
Object? title = freezed,
Object? author = freezed,
Object? description = freezed,
Object? duration = freezed,
Object? viewCount = freezed,
Object? thumbnails = freezed,
Object? uploadDate = freezed,
Object? isLive = freezed,
Object? channelId = freezed,
}) {
return _then(_value.copyWith(
id: id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as VideoId,
title: title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
author: author == freezed
? _value.author
: author // ignore: cast_nullable_to_non_nullable
as String,
description: description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
duration: duration == freezed
? _value.duration
: duration // ignore: cast_nullable_to_non_nullable
as String,
viewCount: viewCount == freezed
? _value.viewCount
: viewCount // ignore: cast_nullable_to_non_nullable
as int,
thumbnails: thumbnails == freezed
? _value.thumbnails
: thumbnails // ignore: cast_nullable_to_non_nullable
as List<Thumbnail>,
uploadDate: uploadDate == freezed
? _value.uploadDate
: uploadDate // ignore: cast_nullable_to_non_nullable
as String?,
isLive: isLive == freezed
? _value.isLive
: isLive // ignore: cast_nullable_to_non_nullable
as bool,
channelId: channelId == freezed
? _value.channelId
: channelId // ignore: cast_nullable_to_non_nullable
as String,
));
}
@override
$VideoIdCopyWith<$Res> get id {
return $VideoIdCopyWith<$Res>(_value.id, (value) {
return _then(_value.copyWith(id: value));
});
}
}
/// @nodoc
abstract class _$SearchVideoCopyWith<$Res>
implements $SearchVideoCopyWith<$Res> {
factory _$SearchVideoCopyWith(
_SearchVideo value, $Res Function(_SearchVideo) then) =
__$SearchVideoCopyWithImpl<$Res>;
@override
$Res call(
{VideoId id,
String title,
String author,
String description,
String duration,
int viewCount,
List<Thumbnail> thumbnails,
String? uploadDate,
bool isLive,
String channelId});
@override
$VideoIdCopyWith<$Res> get id;
}
/// @nodoc
class __$SearchVideoCopyWithImpl<$Res> extends _$SearchVideoCopyWithImpl<$Res>
implements _$SearchVideoCopyWith<$Res> {
__$SearchVideoCopyWithImpl(
_SearchVideo _value, $Res Function(_SearchVideo) _then)
: super(_value, (v) => _then(v as _SearchVideo));
@override
_SearchVideo get _value => super._value as _SearchVideo;
@override
$Res call({
Object? id = freezed,
Object? title = freezed,
Object? author = freezed,
Object? description = freezed,
Object? duration = freezed,
Object? viewCount = freezed,
Object? thumbnails = freezed,
Object? uploadDate = freezed,
Object? isLive = freezed,
Object? channelId = freezed,
}) {
return _then(_SearchVideo(
id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as VideoId,
title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
author == freezed
? _value.author
: author // ignore: cast_nullable_to_non_nullable
as String,
description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
duration == freezed
? _value.duration
: duration // ignore: cast_nullable_to_non_nullable
as String,
viewCount == freezed
? _value.viewCount
: viewCount // ignore: cast_nullable_to_non_nullable
as int,
thumbnails == freezed
? _value.thumbnails
: thumbnails // ignore: cast_nullable_to_non_nullable
as List<Thumbnail>,
uploadDate == freezed
? _value.uploadDate
: uploadDate // ignore: cast_nullable_to_non_nullable
as String?,
isLive == freezed
? _value.isLive
: isLive // ignore: cast_nullable_to_non_nullable
as bool,
channelId == freezed
? _value.channelId
: channelId // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@With(BaseSearchContent)
class _$_SearchVideo with BaseSearchContent implements _SearchVideo {
const _$_SearchVideo(
this.id,
this.title,
this.author,
this.description,
this.duration,
this.viewCount,
this.thumbnails,
this.uploadDate,
this.isLive,
this.channelId);
@override
/// Video ID.
final VideoId id;
@override
/// Video title.
final String title;
@override
/// Video author.
final String author;
@override
/// Video description snippet. (Part of the full description if too long)
final String description;
@override
/// Video duration as String, HH:MM:SS
final String duration;
@override
/// Video View Count
final int viewCount;
@override
/// Video thumbnail
final List<Thumbnail> thumbnails;
@override
/// Video upload date - As string: 5 years ago.
final String? uploadDate;
@override
/// True if this video is a live stream.
final bool isLive;
@override
/// Channel id
final String channelId;
@override
String toString() {
return 'SearchVideo(id: $id, title: $title, author: $author, description: $description, duration: $duration, viewCount: $viewCount, thumbnails: $thumbnails, uploadDate: $uploadDate, isLive: $isLive, channelId: $channelId)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _SearchVideo &&
(identical(other.id, id) ||
const DeepCollectionEquality().equals(other.id, id)) &&
(identical(other.title, title) ||
const DeepCollectionEquality().equals(other.title, title)) &&
(identical(other.author, author) ||
const DeepCollectionEquality().equals(other.author, author)) &&
(identical(other.description, description) ||
const DeepCollectionEquality()
.equals(other.description, description)) &&
(identical(other.duration, duration) ||
const DeepCollectionEquality()
.equals(other.duration, duration)) &&
(identical(other.viewCount, viewCount) ||
const DeepCollectionEquality()
.equals(other.viewCount, viewCount)) &&
(identical(other.thumbnails, thumbnails) ||
const DeepCollectionEquality()
.equals(other.thumbnails, thumbnails)) &&
(identical(other.uploadDate, uploadDate) ||
const DeepCollectionEquality()
.equals(other.uploadDate, uploadDate)) &&
(identical(other.isLive, isLive) ||
const DeepCollectionEquality().equals(other.isLive, isLive)) &&
(identical(other.channelId, channelId) ||
const DeepCollectionEquality()
.equals(other.channelId, channelId)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(id) ^
const DeepCollectionEquality().hash(title) ^
const DeepCollectionEquality().hash(author) ^
const DeepCollectionEquality().hash(description) ^
const DeepCollectionEquality().hash(duration) ^
const DeepCollectionEquality().hash(viewCount) ^
const DeepCollectionEquality().hash(thumbnails) ^
const DeepCollectionEquality().hash(uploadDate) ^
const DeepCollectionEquality().hash(isLive) ^
const DeepCollectionEquality().hash(channelId);
@JsonKey(ignore: true)
@override
_$SearchVideoCopyWith<_SearchVideo> get copyWith =>
__$SearchVideoCopyWithImpl<_SearchVideo>(this, _$identity);
}
abstract class _SearchVideo implements SearchVideo, BaseSearchContent {
const factory _SearchVideo(
VideoId id,
String title,
String author,
String description,
String duration,
int viewCount,
List<Thumbnail> thumbnails,
String? uploadDate,
bool isLive,
String channelId) = _$_SearchVideo;
@override
/// Video ID.
VideoId get id => throw _privateConstructorUsedError;
@override
/// Video title.
String get title => throw _privateConstructorUsedError;
@override
/// Video author.
String get author => throw _privateConstructorUsedError;
@override
/// Video description snippet. (Part of the full description if too long)
String get description => throw _privateConstructorUsedError;
@override
/// Video duration as String, HH:MM:SS
String get duration => throw _privateConstructorUsedError;
@override
/// Video View Count
int get viewCount => throw _privateConstructorUsedError;
@override
/// Video thumbnail
List<Thumbnail> get thumbnails => throw _privateConstructorUsedError;
@override
/// Video upload date - As string: 5 years ago.
String? get uploadDate => throw _privateConstructorUsedError;
@override
/// True if this video is a live stream.
bool get isLive => throw _privateConstructorUsedError;
@override
/// Channel id
String get channelId => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$SearchVideoCopyWith<_SearchVideo> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -6,15 +6,14 @@ part of 'closed_caption.dart';
// JsonSerializableGenerator
// **************************************************************************
ClosedCaption _$ClosedCaptionFromJson(Map<String, dynamic> json) {
return ClosedCaption(
json['text'] as String,
Duration(microseconds: json['offset'] as int),
Duration(microseconds: json['duration'] as int),
(json['parts'] as List<dynamic>)
.map((e) => ClosedCaptionPart.fromJson(e as Map<String, dynamic>)),
);
}
ClosedCaption _$ClosedCaptionFromJson(Map<String, dynamic> json) =>
ClosedCaption(
json['text'] as String,
Duration(microseconds: json['offset'] as int),
Duration(microseconds: json['duration'] as int),
(json['parts'] as List<dynamic>)
.map((e) => ClosedCaptionPart.fromJson(e as Map<String, dynamic>)),
);
Map<String, dynamic> _$ClosedCaptionToJson(ClosedCaption instance) =>
<String, dynamic>{

View File

@ -6,11 +6,10 @@ part of 'closed_caption_format.dart';
// JsonSerializableGenerator
// **************************************************************************
ClosedCaptionFormat _$ClosedCaptionFormatFromJson(Map<String, dynamic> json) {
return ClosedCaptionFormat(
json['formatCode'] as String,
);
}
ClosedCaptionFormat _$ClosedCaptionFormatFromJson(Map<String, dynamic> json) =>
ClosedCaptionFormat(
json['formatCode'] as String,
);
Map<String, dynamic> _$ClosedCaptionFormatToJson(
ClosedCaptionFormat instance) =>

View File

@ -6,12 +6,11 @@ part of 'closed_caption_part.dart';
// JsonSerializableGenerator
// **************************************************************************
ClosedCaptionPart _$ClosedCaptionPartFromJson(Map<String, dynamic> json) {
return ClosedCaptionPart(
json['text'] as String,
Duration(microseconds: json['offset'] as int),
);
}
ClosedCaptionPart _$ClosedCaptionPartFromJson(Map<String, dynamic> json) =>
ClosedCaptionPart(
json['text'] as String,
Duration(microseconds: json['offset'] as int),
);
Map<String, dynamic> _$ClosedCaptionPartToJson(ClosedCaptionPart instance) =>
<String, dynamic>{

View File

@ -6,12 +6,11 @@ part of 'closed_caption_track.dart';
// JsonSerializableGenerator
// **************************************************************************
ClosedCaptionTrack _$ClosedCaptionTrackFromJson(Map<String, dynamic> json) {
return ClosedCaptionTrack(
(json['captions'] as List<dynamic>)
.map((e) => ClosedCaption.fromJson(e as Map<String, dynamic>)),
);
}
ClosedCaptionTrack _$ClosedCaptionTrackFromJson(Map<String, dynamic> json) =>
ClosedCaptionTrack(
(json['captions'] as List<dynamic>)
.map((e) => ClosedCaption.fromJson(e as Map<String, dynamic>)),
);
Map<String, dynamic> _$ClosedCaptionTrackToJson(ClosedCaptionTrack instance) =>
<String, dynamic>{

View File

@ -7,15 +7,14 @@ part of 'closed_caption_track_info.dart';
// **************************************************************************
ClosedCaptionTrackInfo _$ClosedCaptionTrackInfoFromJson(
Map<String, dynamic> json) {
return ClosedCaptionTrackInfo(
Uri.parse(json['url'] as String),
Language.fromJson(json['language'] as Map<String, dynamic>),
isAutoGenerated: json['isAutoGenerated'] as bool,
format:
ClosedCaptionFormat.fromJson(json['format'] as Map<String, dynamic>),
);
}
Map<String, dynamic> json) =>
ClosedCaptionTrackInfo(
Uri.parse(json['url'] as String),
Language.fromJson(json['language'] as Map<String, dynamic>),
isAutoGenerated: json['isAutoGenerated'] as bool? ?? false,
format:
ClosedCaptionFormat.fromJson(json['format'] as Map<String, dynamic>),
);
Map<String, dynamic> _$ClosedCaptionTrackInfoToJson(
ClosedCaptionTrackInfo instance) =>

View File

@ -6,12 +6,10 @@ part of 'language.dart';
// JsonSerializableGenerator
// **************************************************************************
Language _$LanguageFromJson(Map<String, dynamic> json) {
return Language(
json['code'] as String,
json['name'] as String,
);
}
Language _$LanguageFromJson(Map<String, dynamic> json) => Language(
json['code'] as String,
json['name'] as String,
);
Map<String, dynamic> _$LanguageToJson(Language instance) => <String, dynamic>{
'code': instance.code,

View File

@ -1,53 +1,41 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../channels/channel_id.dart';
part 'comment.freezed.dart';
/// YouTube comment metadata.
class Comment with EquatableMixin {
/// Comment id.
final String commentId;
/// Comment author name.
final String author;
/// Comment author channel id.
final ChannelId channelId;
/// Comment text.
final String text;
/// Comment likes count.
final int likeCount;
/// Published time as string. (For example: "2 years ago")
final String publishedTime;
/// Comment reply count.
final int replyCount;
/// Used internally.
/// Shouldn't be used in the code.
final String? continuation;
/// Used internally.
/// Shouldn't be used in the code.
final String? clicktrackingParams;
@freezed
class Comment with _$Comment {
/// Initializes an instance of [Comment]
Comment(
this.commentId,
this.author,
this.channelId,
this.text,
this.likeCount,
this.publishedTime,
this.replyCount,
this.continuation,
this.clicktrackingParams);
const factory Comment(
/// Comment id.
String commentId,
@override
String toString() => 'Comment($author): $text';
/// Comment author name.
String author,
@override
List<Object> get props => [commentId];
/// Comment author channel id.
ChannelId channelId,
/// Comment text.
String text,
/// Comment likes count.
int likeCount,
/// Published time as string. (For example: "2 years ago")
String publishedTime,
/// Comment reply count.
int replyCount,
/// Used internally.
/// Shouldn't be used in the code.
@internal String? continuation,
/// Used internally.
/// Shouldn't be used in the code.
@internal String? clicktrackingParams,
) = _Comment;
}

View File

@ -0,0 +1,417 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'comment.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$CommentTearOff {
const _$CommentTearOff();
_Comment call(
String commentId,
String author,
ChannelId channelId,
String text,
int likeCount,
String publishedTime,
int replyCount,
@internal String? continuation,
@internal String? clicktrackingParams) {
return _Comment(
commentId,
author,
channelId,
text,
likeCount,
publishedTime,
replyCount,
continuation,
clicktrackingParams,
);
}
}
/// @nodoc
const $Comment = _$CommentTearOff();
/// @nodoc
mixin _$Comment {
/// Comment id.
String get commentId => throw _privateConstructorUsedError;
/// Comment author name.
String get author => throw _privateConstructorUsedError;
/// Comment author channel id.
ChannelId get channelId => throw _privateConstructorUsedError;
/// Comment text.
String get text => throw _privateConstructorUsedError;
/// Comment likes count.
int get likeCount => throw _privateConstructorUsedError;
/// Published time as string. (For example: "2 years ago")
String get publishedTime => throw _privateConstructorUsedError;
/// Comment reply count.
int get replyCount => throw _privateConstructorUsedError;
/// Used internally.
/// Shouldn't be used in the code.
@internal
String? get continuation => throw _privateConstructorUsedError;
/// Used internally.
/// Shouldn't be used in the code.
@internal
String? get clicktrackingParams => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$CommentCopyWith<Comment> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CommentCopyWith<$Res> {
factory $CommentCopyWith(Comment value, $Res Function(Comment) then) =
_$CommentCopyWithImpl<$Res>;
$Res call(
{String commentId,
String author,
ChannelId channelId,
String text,
int likeCount,
String publishedTime,
int replyCount,
@internal String? continuation,
@internal String? clicktrackingParams});
$ChannelIdCopyWith<$Res> get channelId;
}
/// @nodoc
class _$CommentCopyWithImpl<$Res> implements $CommentCopyWith<$Res> {
_$CommentCopyWithImpl(this._value, this._then);
final Comment _value;
// ignore: unused_field
final $Res Function(Comment) _then;
@override
$Res call({
Object? commentId = freezed,
Object? author = freezed,
Object? channelId = freezed,
Object? text = freezed,
Object? likeCount = freezed,
Object? publishedTime = freezed,
Object? replyCount = freezed,
Object? continuation = freezed,
Object? clicktrackingParams = freezed,
}) {
return _then(_value.copyWith(
commentId: commentId == freezed
? _value.commentId
: commentId // ignore: cast_nullable_to_non_nullable
as String,
author: author == freezed
? _value.author
: author // ignore: cast_nullable_to_non_nullable
as String,
channelId: channelId == freezed
? _value.channelId
: channelId // ignore: cast_nullable_to_non_nullable
as ChannelId,
text: text == freezed
? _value.text
: text // ignore: cast_nullable_to_non_nullable
as String,
likeCount: likeCount == freezed
? _value.likeCount
: likeCount // ignore: cast_nullable_to_non_nullable
as int,
publishedTime: publishedTime == freezed
? _value.publishedTime
: publishedTime // ignore: cast_nullable_to_non_nullable
as String,
replyCount: replyCount == freezed
? _value.replyCount
: replyCount // ignore: cast_nullable_to_non_nullable
as int,
continuation: continuation == freezed
? _value.continuation
: continuation // ignore: cast_nullable_to_non_nullable
as String?,
clicktrackingParams: clicktrackingParams == freezed
? _value.clicktrackingParams
: clicktrackingParams // ignore: cast_nullable_to_non_nullable
as String?,
));
}
@override
$ChannelIdCopyWith<$Res> get channelId {
return $ChannelIdCopyWith<$Res>(_value.channelId, (value) {
return _then(_value.copyWith(channelId: value));
});
}
}
/// @nodoc
abstract class _$CommentCopyWith<$Res> implements $CommentCopyWith<$Res> {
factory _$CommentCopyWith(_Comment value, $Res Function(_Comment) then) =
__$CommentCopyWithImpl<$Res>;
@override
$Res call(
{String commentId,
String author,
ChannelId channelId,
String text,
int likeCount,
String publishedTime,
int replyCount,
@internal String? continuation,
@internal String? clicktrackingParams});
@override
$ChannelIdCopyWith<$Res> get channelId;
}
/// @nodoc
class __$CommentCopyWithImpl<$Res> extends _$CommentCopyWithImpl<$Res>
implements _$CommentCopyWith<$Res> {
__$CommentCopyWithImpl(_Comment _value, $Res Function(_Comment) _then)
: super(_value, (v) => _then(v as _Comment));
@override
_Comment get _value => super._value as _Comment;
@override
$Res call({
Object? commentId = freezed,
Object? author = freezed,
Object? channelId = freezed,
Object? text = freezed,
Object? likeCount = freezed,
Object? publishedTime = freezed,
Object? replyCount = freezed,
Object? continuation = freezed,
Object? clicktrackingParams = freezed,
}) {
return _then(_Comment(
commentId == freezed
? _value.commentId
: commentId // ignore: cast_nullable_to_non_nullable
as String,
author == freezed
? _value.author
: author // ignore: cast_nullable_to_non_nullable
as String,
channelId == freezed
? _value.channelId
: channelId // ignore: cast_nullable_to_non_nullable
as ChannelId,
text == freezed
? _value.text
: text // ignore: cast_nullable_to_non_nullable
as String,
likeCount == freezed
? _value.likeCount
: likeCount // ignore: cast_nullable_to_non_nullable
as int,
publishedTime == freezed
? _value.publishedTime
: publishedTime // ignore: cast_nullable_to_non_nullable
as String,
replyCount == freezed
? _value.replyCount
: replyCount // ignore: cast_nullable_to_non_nullable
as int,
continuation == freezed
? _value.continuation
: continuation // ignore: cast_nullable_to_non_nullable
as String?,
clicktrackingParams == freezed
? _value.clicktrackingParams
: clicktrackingParams // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
class _$_Comment implements _Comment {
const _$_Comment(
this.commentId,
this.author,
this.channelId,
this.text,
this.likeCount,
this.publishedTime,
this.replyCount,
@internal this.continuation,
@internal this.clicktrackingParams);
@override
/// Comment id.
final String commentId;
@override
/// Comment author name.
final String author;
@override
/// Comment author channel id.
final ChannelId channelId;
@override
/// Comment text.
final String text;
@override
/// Comment likes count.
final int likeCount;
@override
/// Published time as string. (For example: "2 years ago")
final String publishedTime;
@override
/// Comment reply count.
final int replyCount;
@override
/// Used internally.
/// Shouldn't be used in the code.
@internal
final String? continuation;
@override
/// Used internally.
/// Shouldn't be used in the code.
@internal
final String? clicktrackingParams;
@override
String toString() {
return 'Comment(commentId: $commentId, author: $author, channelId: $channelId, text: $text, likeCount: $likeCount, publishedTime: $publishedTime, replyCount: $replyCount, continuation: $continuation, clicktrackingParams: $clicktrackingParams)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _Comment &&
(identical(other.commentId, commentId) ||
const DeepCollectionEquality()
.equals(other.commentId, commentId)) &&
(identical(other.author, author) ||
const DeepCollectionEquality().equals(other.author, author)) &&
(identical(other.channelId, channelId) ||
const DeepCollectionEquality()
.equals(other.channelId, channelId)) &&
(identical(other.text, text) ||
const DeepCollectionEquality().equals(other.text, text)) &&
(identical(other.likeCount, likeCount) ||
const DeepCollectionEquality()
.equals(other.likeCount, likeCount)) &&
(identical(other.publishedTime, publishedTime) ||
const DeepCollectionEquality()
.equals(other.publishedTime, publishedTime)) &&
(identical(other.replyCount, replyCount) ||
const DeepCollectionEquality()
.equals(other.replyCount, replyCount)) &&
(identical(other.continuation, continuation) ||
const DeepCollectionEquality()
.equals(other.continuation, continuation)) &&
(identical(other.clicktrackingParams, clicktrackingParams) ||
const DeepCollectionEquality()
.equals(other.clicktrackingParams, clicktrackingParams)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(commentId) ^
const DeepCollectionEquality().hash(author) ^
const DeepCollectionEquality().hash(channelId) ^
const DeepCollectionEquality().hash(text) ^
const DeepCollectionEquality().hash(likeCount) ^
const DeepCollectionEquality().hash(publishedTime) ^
const DeepCollectionEquality().hash(replyCount) ^
const DeepCollectionEquality().hash(continuation) ^
const DeepCollectionEquality().hash(clicktrackingParams);
@JsonKey(ignore: true)
@override
_$CommentCopyWith<_Comment> get copyWith =>
__$CommentCopyWithImpl<_Comment>(this, _$identity);
}
abstract class _Comment implements Comment {
const factory _Comment(
String commentId,
String author,
ChannelId channelId,
String text,
int likeCount,
String publishedTime,
int replyCount,
@internal String? continuation,
@internal String? clicktrackingParams) = _$_Comment;
@override
/// Comment id.
String get commentId => throw _privateConstructorUsedError;
@override
/// Comment author name.
String get author => throw _privateConstructorUsedError;
@override
/// Comment author channel id.
ChannelId get channelId => throw _privateConstructorUsedError;
@override
/// Comment text.
String get text => throw _privateConstructorUsedError;
@override
/// Comment likes count.
int get likeCount => throw _privateConstructorUsedError;
@override
/// Published time as string. (For example: "2 years ago")
String get publishedTime => throw _privateConstructorUsedError;
@override
/// Comment reply count.
int get replyCount => throw _privateConstructorUsedError;
@override
/// Used internally.
/// Shouldn't be used in the code.
@internal
String? get continuation => throw _privateConstructorUsedError;
@override
/// Used internally.
/// Shouldn't be used in the code.
@internal
String? get clicktrackingParams => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$CommentCopyWith<_Comment> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,10 +1,10 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'bitrate.freezed.dart';
/// Encapsulates bitrate.
class Bitrate extends Comparable<Bitrate> with EquatableMixin {
/// Bits per second.
final int bitsPerSecond;
@freezed
class Bitrate with Comparable<Bitrate>, _$Bitrate {
/// Kilobits per second.
double get kiloBitsPerSecond => bitsPerSecond / 1024;
@ -15,7 +15,13 @@ class Bitrate extends Comparable<Bitrate> with EquatableMixin {
double get gigaBitsPerSecond => megaBitsPerSecond / 1024;
/// Initializes an instance of [Bitrate]
Bitrate(this.bitsPerSecond);
@With.fromString('Comparable<Bitrate>')
const factory Bitrate(
/// Bits per second.
int bitsPerSecond) = _Bitrate;
const Bitrate._();
@override
int compareTo(Bitrate other) => bitsPerSecond.compareTo(other.bitsPerSecond);

View File

@ -0,0 +1,138 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'bitrate.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$BitrateTearOff {
const _$BitrateTearOff();
_Bitrate call(int bitsPerSecond) {
return _Bitrate(
bitsPerSecond,
);
}
}
/// @nodoc
const $Bitrate = _$BitrateTearOff();
/// @nodoc
mixin _$Bitrate {
/// Bits per second.
int get bitsPerSecond => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$BitrateCopyWith<Bitrate> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $BitrateCopyWith<$Res> {
factory $BitrateCopyWith(Bitrate value, $Res Function(Bitrate) then) =
_$BitrateCopyWithImpl<$Res>;
$Res call({int bitsPerSecond});
}
/// @nodoc
class _$BitrateCopyWithImpl<$Res> implements $BitrateCopyWith<$Res> {
_$BitrateCopyWithImpl(this._value, this._then);
final Bitrate _value;
// ignore: unused_field
final $Res Function(Bitrate) _then;
@override
$Res call({
Object? bitsPerSecond = freezed,
}) {
return _then(_value.copyWith(
bitsPerSecond: bitsPerSecond == freezed
? _value.bitsPerSecond
: bitsPerSecond // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
abstract class _$BitrateCopyWith<$Res> implements $BitrateCopyWith<$Res> {
factory _$BitrateCopyWith(_Bitrate value, $Res Function(_Bitrate) then) =
__$BitrateCopyWithImpl<$Res>;
@override
$Res call({int bitsPerSecond});
}
/// @nodoc
class __$BitrateCopyWithImpl<$Res> extends _$BitrateCopyWithImpl<$Res>
implements _$BitrateCopyWith<$Res> {
__$BitrateCopyWithImpl(_Bitrate _value, $Res Function(_Bitrate) _then)
: super(_value, (v) => _then(v as _Bitrate));
@override
_Bitrate get _value => super._value as _Bitrate;
@override
$Res call({
Object? bitsPerSecond = freezed,
}) {
return _then(_Bitrate(
bitsPerSecond == freezed
? _value.bitsPerSecond
: bitsPerSecond // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@With.fromString('Comparable<Bitrate>')
class _$_Bitrate extends _Bitrate with Comparable<Bitrate> {
const _$_Bitrate(this.bitsPerSecond) : super._();
@override
/// Bits per second.
final int bitsPerSecond;
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _Bitrate &&
(identical(other.bitsPerSecond, bitsPerSecond) ||
const DeepCollectionEquality()
.equals(other.bitsPerSecond, bitsPerSecond)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(bitsPerSecond);
@JsonKey(ignore: true)
@override
_$BitrateCopyWith<_Bitrate> get copyWith =>
__$BitrateCopyWithImpl<_Bitrate>(this, _$identity);
}
abstract class _Bitrate extends Bitrate implements Comparable<Bitrate> {
const factory _Bitrate(int bitsPerSecond) = _$_Bitrate;
const _Bitrate._() : super._();
@override
/// Bits per second.
int get bitsPerSecond => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$BitrateCopyWith<_Bitrate> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,10 +1,10 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'filesize.freezed.dart';
/// Encapsulates file size.
class FileSize extends Comparable<FileSize> with EquatableMixin {
/// Total bytes.
final int totalBytes;
@freezed
class FileSize with Comparable<FileSize>, _$FileSize {
/// Total kilobytes.
double get totalKiloBytes => totalBytes / 1024;
@ -15,7 +15,13 @@ class FileSize extends Comparable<FileSize> with EquatableMixin {
double get totalGigaBytes => totalMegaBytes / 1024;
/// Initializes an instance of [FileSize]
FileSize(this.totalBytes);
@With.fromString('Comparable<FileSize>')
const factory FileSize(
/// Total bytes.
int totalBytes) = _FileSize;
const FileSize._();
@override
int compareTo(FileSize other) => totalBytes.compareTo(other.totalBytes);
@ -48,7 +54,4 @@ class FileSize extends Comparable<FileSize> with EquatableMixin {
@override
String toString() => '${_getLargestValue()} ${_getLargestSymbol()}';
@override
List<Object> get props => [totalBytes];
}

View File

@ -0,0 +1,139 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'filesize.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$FileSizeTearOff {
const _$FileSizeTearOff();
_FileSize call(int totalBytes) {
return _FileSize(
totalBytes,
);
}
}
/// @nodoc
const $FileSize = _$FileSizeTearOff();
/// @nodoc
mixin _$FileSize {
/// Total bytes.
int get totalBytes => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$FileSizeCopyWith<FileSize> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $FileSizeCopyWith<$Res> {
factory $FileSizeCopyWith(FileSize value, $Res Function(FileSize) then) =
_$FileSizeCopyWithImpl<$Res>;
$Res call({int totalBytes});
}
/// @nodoc
class _$FileSizeCopyWithImpl<$Res> implements $FileSizeCopyWith<$Res> {
_$FileSizeCopyWithImpl(this._value, this._then);
final FileSize _value;
// ignore: unused_field
final $Res Function(FileSize) _then;
@override
$Res call({
Object? totalBytes = freezed,
}) {
return _then(_value.copyWith(
totalBytes: totalBytes == freezed
? _value.totalBytes
: totalBytes // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
abstract class _$FileSizeCopyWith<$Res> implements $FileSizeCopyWith<$Res> {
factory _$FileSizeCopyWith(_FileSize value, $Res Function(_FileSize) then) =
__$FileSizeCopyWithImpl<$Res>;
@override
$Res call({int totalBytes});
}
/// @nodoc
class __$FileSizeCopyWithImpl<$Res> extends _$FileSizeCopyWithImpl<$Res>
implements _$FileSizeCopyWith<$Res> {
__$FileSizeCopyWithImpl(_FileSize _value, $Res Function(_FileSize) _then)
: super(_value, (v) => _then(v as _FileSize));
@override
_FileSize get _value => super._value as _FileSize;
@override
$Res call({
Object? totalBytes = freezed,
}) {
return _then(_FileSize(
totalBytes == freezed
? _value.totalBytes
: totalBytes // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@With.fromString('Comparable<FileSize>')
class _$_FileSize extends _FileSize with Comparable<FileSize> {
const _$_FileSize(this.totalBytes) : super._();
@override
/// Total bytes.
final int totalBytes;
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _FileSize &&
(identical(other.totalBytes, totalBytes) ||
const DeepCollectionEquality()
.equals(other.totalBytes, totalBytes)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(totalBytes);
@JsonKey(ignore: true)
@override
_$FileSizeCopyWith<_FileSize> get copyWith =>
__$FileSizeCopyWithImpl<_FileSize>(this, _$identity);
}
abstract class _FileSize extends FileSize implements Comparable<FileSize> {
const factory _FileSize(int totalBytes) = _$_FileSize;
const _FileSize._() : super._();
@override
/// Total bytes.
int get totalBytes => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$FileSizeCopyWith<_FileSize> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,12 +1,17 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'framerate.freezed.dart';
/// Encapsulates framerate.
class Framerate extends Comparable<Framerate> with EquatableMixin {
/// Framerate as frames per second
final num framesPerSecond;
@freezed
class Framerate with Comparable<Framerate>, _$Framerate {
/// Initialize an instance of [Framerate]
Framerate(this.framesPerSecond);
const factory Framerate(
/// Framerate as frames per second
num framesPerSecond) = _Framerate;
const Framerate._();
///
bool operator >(Framerate other) => framesPerSecond > other.framesPerSecond;
@ -17,9 +22,6 @@ class Framerate extends Comparable<Framerate> with EquatableMixin {
@override
String toString() => '$framesPerSecond FPS';
@override
List<Object> get props => [framesPerSecond];
@override
int compareTo(Framerate other) =>
framesPerSecond.compareTo(other.framesPerSecond);

View File

@ -0,0 +1,140 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'framerate.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$FramerateTearOff {
const _$FramerateTearOff();
_Framerate call(num framesPerSecond) {
return _Framerate(
framesPerSecond,
);
}
}
/// @nodoc
const $Framerate = _$FramerateTearOff();
/// @nodoc
mixin _$Framerate {
/// Framerate as frames per second
num get framesPerSecond => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$FramerateCopyWith<Framerate> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $FramerateCopyWith<$Res> {
factory $FramerateCopyWith(Framerate value, $Res Function(Framerate) then) =
_$FramerateCopyWithImpl<$Res>;
$Res call({num framesPerSecond});
}
/// @nodoc
class _$FramerateCopyWithImpl<$Res> implements $FramerateCopyWith<$Res> {
_$FramerateCopyWithImpl(this._value, this._then);
final Framerate _value;
// ignore: unused_field
final $Res Function(Framerate) _then;
@override
$Res call({
Object? framesPerSecond = freezed,
}) {
return _then(_value.copyWith(
framesPerSecond: framesPerSecond == freezed
? _value.framesPerSecond
: framesPerSecond // ignore: cast_nullable_to_non_nullable
as num,
));
}
}
/// @nodoc
abstract class _$FramerateCopyWith<$Res> implements $FramerateCopyWith<$Res> {
factory _$FramerateCopyWith(
_Framerate value, $Res Function(_Framerate) then) =
__$FramerateCopyWithImpl<$Res>;
@override
$Res call({num framesPerSecond});
}
/// @nodoc
class __$FramerateCopyWithImpl<$Res> extends _$FramerateCopyWithImpl<$Res>
implements _$FramerateCopyWith<$Res> {
__$FramerateCopyWithImpl(_Framerate _value, $Res Function(_Framerate) _then)
: super(_value, (v) => _then(v as _Framerate));
@override
_Framerate get _value => super._value as _Framerate;
@override
$Res call({
Object? framesPerSecond = freezed,
}) {
return _then(_Framerate(
framesPerSecond == freezed
? _value.framesPerSecond
: framesPerSecond // ignore: cast_nullable_to_non_nullable
as num,
));
}
}
/// @nodoc
class _$_Framerate extends _Framerate {
const _$_Framerate(this.framesPerSecond) : super._();
@override
/// Framerate as frames per second
final num framesPerSecond;
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _Framerate &&
(identical(other.framesPerSecond, framesPerSecond) ||
const DeepCollectionEquality()
.equals(other.framesPerSecond, framesPerSecond)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(framesPerSecond);
@JsonKey(ignore: true)
@override
_$FramerateCopyWith<_Framerate> get copyWith =>
__$FramerateCopyWithImpl<_Framerate>(this, _$identity);
}
abstract class _Framerate extends Framerate {
const factory _Framerate(num framesPerSecond) = _$_Framerate;
const _Framerate._() : super._();
@override
/// Framerate as frames per second
num get framesPerSecond => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$FramerateCopyWith<_Framerate> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,25 +1,30 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'stream_container.freezed.dart';
/// Stream container.
class StreamContainer with EquatableMixin {
/// Container name.
/// Can be used as file extension
final String name;
@freezed
class StreamContainer with _$StreamContainer {
/// Initializes an instance of [StreamContainer]
StreamContainer._(this.name);
const factory StreamContainer._internal(
/// Container name.
/// Can be used as file extension
String name) = _StreamContainer;
const StreamContainer._();
/// MPEG-4 Part 14 (.mp4).
static final StreamContainer mp4 = StreamContainer._('mp4');
static const StreamContainer mp4 = StreamContainer._internal('mp4');
/// Web Media (.webm).
static final StreamContainer webM = StreamContainer._('webm');
static const StreamContainer webM = StreamContainer._internal('webm');
/// 3rd Generation Partnership Project (.3gpp).
static final StreamContainer tgpp = StreamContainer._('3gpp');
static const StreamContainer tgpp = StreamContainer._internal('3gpp');
/// Parse a container from name.
static StreamContainer parse(String name) {
factory StreamContainer.parse(String name) {
if (name.toLowerCase() == 'mp4') {
return StreamContainer.mp4;
}
@ -33,9 +38,6 @@ class StreamContainer with EquatableMixin {
throw ArgumentError.value(name, 'name', 'Valid values: mp4, webm, 3gpp');
}
@override
List<Object> get props => [name];
@override
String toString() => name;
}

View File

@ -0,0 +1,146 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'stream_container.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$StreamContainerTearOff {
const _$StreamContainerTearOff();
_StreamContainer _internal(String name) {
return _StreamContainer(
name,
);
}
}
/// @nodoc
const $StreamContainer = _$StreamContainerTearOff();
/// @nodoc
mixin _$StreamContainer {
/// Container name.
/// Can be used as file extension
String get name => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$StreamContainerCopyWith<StreamContainer> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $StreamContainerCopyWith<$Res> {
factory $StreamContainerCopyWith(
StreamContainer value, $Res Function(StreamContainer) then) =
_$StreamContainerCopyWithImpl<$Res>;
$Res call({String name});
}
/// @nodoc
class _$StreamContainerCopyWithImpl<$Res>
implements $StreamContainerCopyWith<$Res> {
_$StreamContainerCopyWithImpl(this._value, this._then);
final StreamContainer _value;
// ignore: unused_field
final $Res Function(StreamContainer) _then;
@override
$Res call({
Object? name = freezed,
}) {
return _then(_value.copyWith(
name: name == freezed
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
abstract class _$StreamContainerCopyWith<$Res>
implements $StreamContainerCopyWith<$Res> {
factory _$StreamContainerCopyWith(
_StreamContainer value, $Res Function(_StreamContainer) then) =
__$StreamContainerCopyWithImpl<$Res>;
@override
$Res call({String name});
}
/// @nodoc
class __$StreamContainerCopyWithImpl<$Res>
extends _$StreamContainerCopyWithImpl<$Res>
implements _$StreamContainerCopyWith<$Res> {
__$StreamContainerCopyWithImpl(
_StreamContainer _value, $Res Function(_StreamContainer) _then)
: super(_value, (v) => _then(v as _StreamContainer));
@override
_StreamContainer get _value => super._value as _StreamContainer;
@override
$Res call({
Object? name = freezed,
}) {
return _then(_StreamContainer(
name == freezed
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$_StreamContainer extends _StreamContainer {
const _$_StreamContainer(this.name) : super._();
@override
/// Container name.
/// Can be used as file extension
final String name;
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _StreamContainer &&
(identical(other.name, name) ||
const DeepCollectionEquality().equals(other.name, name)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(name);
@JsonKey(ignore: true)
@override
_$StreamContainerCopyWith<_StreamContainer> get copyWith =>
__$StreamContainerCopyWithImpl<_StreamContainer>(this, _$identity);
}
abstract class _StreamContainer extends StreamContainer {
const factory _StreamContainer(String name) = _$_StreamContainer;
const _StreamContainer._() : super._();
@override
/// Container name.
/// Can be used as file extension
String get name => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$StreamContainerCopyWith<_StreamContainer> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,6 +1,6 @@
import 'dart:collection';
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:meta/meta.dart';
import '../channels/channel_id.dart';
@ -8,77 +8,138 @@ import '../common/common.dart';
import '../reverse_engineering/responses/responses.dart';
import 'video_id.dart';
/// YouTube video metadata.
class Video with EquatableMixin {
/// Video ID.
final VideoId id;
part 'video.freezed.dart';
/// YouTube video metadata.
@freezed
class Video with _$Video {
/// Video URL.
String get url => 'https://www.youtube.com/watch?v=$id';
/// Video title.
final String title;
/// Video author.
final String author;
/// Video author Id.
final ChannelId channelId;
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
final DateTime? uploadDate;
/// Video publish date.
final DateTime? publishDate;
/// Video description.
final String description;
/// Duration of the video.
final Duration? duration;
/// Available thumbnails for this video.
final ThumbnailSet thumbnails;
/// Search keywords used for this video.
final UnmodifiableListView<String> keywords;
/// Engagement statistics for this video.
final Engagement engagement;
/// Returns true if this is a live stream.
final bool isLive;
/// Used internally.
/// Shouldn't be used in the code.
@internal
final WatchPage? watchPage;
/// Returns true if the watch page is available for this video.
bool get hasWatchPage => watchPage != null;
/// Initializes an instance of [Video]
Video(
this.id,
this.title,
this.author,
this.channelId,
this.uploadDate,
this.publishDate,
this.description,
this.duration,
this.thumbnails,
factory Video(
/// Video ID.
VideoId id,
/// Video title.
String title,
/// Video author.
String author,
/// Video author Id.
ChannelId channelId,
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
DateTime? uploadDate,
/// Video publish date.
DateTime? publishDate,
/// Video description.
String description,
/// Duration of the video.
Duration? duration,
/// Available thumbnails for this video.
ThumbnailSet thumbnails,
/// Search keywords used for this video.
Iterable<String>? keywords,
this.engagement,
this.isLive, // ignore: avoid_positional_boolean_parameters
[this.watchPage])
: keywords = UnmodifiableListView(keywords ?? const []);
@override
String toString() => 'Video ($title)';
/// Engagement statistics for this video.
Engagement engagement,
@override
List<Object> get props => [id];
/// Returns true if this is a live stream.
//ignore: avoid_positional_boolean_parameters
bool isLive,
[
/// Used internally.
/// Shouldn't be used in the code.
@internal WatchPage? watchPage]) {
return Video._internal(
/// Video ID.
id,
/// Video title.
title,
/// Video author.
author,
/// Video author Id.
channelId,
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
uploadDate,
/// Video publish date.
publishDate,
description,
duration,
thumbnails,
UnmodifiableListView(keywords ?? const Iterable.empty()),
engagement,
isLive,
watchPage);
}
/// Initializes an instance of [Video]
const factory Video._internal(
/// Video ID.
VideoId id,
/// Video title.
String title,
/// Video author.
String author,
/// Video author Id.
ChannelId channelId,
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
DateTime? uploadDate,
/// Video publish date.
DateTime? publishDate,
/// Video description.
String description,
/// Duration of the video.
Duration? duration,
/// Available thumbnails for this video.
ThumbnailSet thumbnails,
/// Search keywords used for this video.
UnmodifiableListView<String> keywords,
/// Engagement statistics for this video.
Engagement engagement,
/// Returns true if this is a live stream.
//ignore: avoid_positional_boolean_parameters
bool isLive,
[
/// Used internally.
/// Shouldn't be used in the code.
@internal WatchPage? watchPage]) = _Video;
const Video._();
}

View File

@ -0,0 +1,575 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'video.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$VideoTearOff {
const _$VideoTearOff();
_Video _internal(
VideoId id,
String title,
String author,
ChannelId channelId,
DateTime? uploadDate,
DateTime? publishDate,
String description,
Duration? duration,
ThumbnailSet thumbnails,
UnmodifiableListView<String> keywords,
Engagement engagement,
bool isLive,
[@internal WatchPage? watchPage]) {
return _Video(
id,
title,
author,
channelId,
uploadDate,
publishDate,
description,
duration,
thumbnails,
keywords,
engagement,
isLive,
watchPage,
);
}
}
/// @nodoc
const $Video = _$VideoTearOff();
/// @nodoc
mixin _$Video {
/// Video ID.
VideoId get id => throw _privateConstructorUsedError;
/// Video title.
String get title => throw _privateConstructorUsedError;
/// Video author.
String get author => throw _privateConstructorUsedError;
/// Video author Id.
ChannelId get channelId => throw _privateConstructorUsedError;
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
DateTime? get uploadDate => throw _privateConstructorUsedError;
/// Video publish date.
DateTime? get publishDate => throw _privateConstructorUsedError;
/// Video description.
String get description => throw _privateConstructorUsedError;
/// Duration of the video.
Duration? get duration => throw _privateConstructorUsedError;
/// Available thumbnails for this video.
ThumbnailSet get thumbnails => throw _privateConstructorUsedError;
/// Search keywords used for this video.
UnmodifiableListView<String> get keywords =>
throw _privateConstructorUsedError;
/// Engagement statistics for this video.
Engagement get engagement => throw _privateConstructorUsedError;
/// Returns true if this is a live stream.
//ignore: avoid_positional_boolean_parameters
bool get isLive => throw _privateConstructorUsedError;
/// Used internally.
/// Shouldn't be used in the code.
@internal
WatchPage? get watchPage => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$VideoCopyWith<Video> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $VideoCopyWith<$Res> {
factory $VideoCopyWith(Video value, $Res Function(Video) then) =
_$VideoCopyWithImpl<$Res>;
$Res call(
{VideoId id,
String title,
String author,
ChannelId channelId,
DateTime? uploadDate,
DateTime? publishDate,
String description,
Duration? duration,
ThumbnailSet thumbnails,
UnmodifiableListView<String> keywords,
Engagement engagement,
bool isLive,
@internal WatchPage? watchPage});
$VideoIdCopyWith<$Res> get id;
$ChannelIdCopyWith<$Res> get channelId;
$ThumbnailSetCopyWith<$Res> get thumbnails;
$EngagementCopyWith<$Res> get engagement;
}
/// @nodoc
class _$VideoCopyWithImpl<$Res> implements $VideoCopyWith<$Res> {
_$VideoCopyWithImpl(this._value, this._then);
final Video _value;
// ignore: unused_field
final $Res Function(Video) _then;
@override
$Res call({
Object? id = freezed,
Object? title = freezed,
Object? author = freezed,
Object? channelId = freezed,
Object? uploadDate = freezed,
Object? publishDate = freezed,
Object? description = freezed,
Object? duration = freezed,
Object? thumbnails = freezed,
Object? keywords = freezed,
Object? engagement = freezed,
Object? isLive = freezed,
Object? watchPage = freezed,
}) {
return _then(_value.copyWith(
id: id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as VideoId,
title: title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
author: author == freezed
? _value.author
: author // ignore: cast_nullable_to_non_nullable
as String,
channelId: channelId == freezed
? _value.channelId
: channelId // ignore: cast_nullable_to_non_nullable
as ChannelId,
uploadDate: uploadDate == freezed
? _value.uploadDate
: uploadDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
publishDate: publishDate == freezed
? _value.publishDate
: publishDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
description: description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
duration: duration == freezed
? _value.duration
: duration // ignore: cast_nullable_to_non_nullable
as Duration?,
thumbnails: thumbnails == freezed
? _value.thumbnails
: thumbnails // ignore: cast_nullable_to_non_nullable
as ThumbnailSet,
keywords: keywords == freezed
? _value.keywords
: keywords // ignore: cast_nullable_to_non_nullable
as UnmodifiableListView<String>,
engagement: engagement == freezed
? _value.engagement
: engagement // ignore: cast_nullable_to_non_nullable
as Engagement,
isLive: isLive == freezed
? _value.isLive
: isLive // ignore: cast_nullable_to_non_nullable
as bool,
watchPage: watchPage == freezed
? _value.watchPage
: watchPage // ignore: cast_nullable_to_non_nullable
as WatchPage?,
));
}
@override
$VideoIdCopyWith<$Res> get id {
return $VideoIdCopyWith<$Res>(_value.id, (value) {
return _then(_value.copyWith(id: value));
});
}
@override
$ChannelIdCopyWith<$Res> get channelId {
return $ChannelIdCopyWith<$Res>(_value.channelId, (value) {
return _then(_value.copyWith(channelId: value));
});
}
@override
$ThumbnailSetCopyWith<$Res> get thumbnails {
return $ThumbnailSetCopyWith<$Res>(_value.thumbnails, (value) {
return _then(_value.copyWith(thumbnails: value));
});
}
@override
$EngagementCopyWith<$Res> get engagement {
return $EngagementCopyWith<$Res>(_value.engagement, (value) {
return _then(_value.copyWith(engagement: value));
});
}
}
/// @nodoc
abstract class _$VideoCopyWith<$Res> implements $VideoCopyWith<$Res> {
factory _$VideoCopyWith(_Video value, $Res Function(_Video) then) =
__$VideoCopyWithImpl<$Res>;
@override
$Res call(
{VideoId id,
String title,
String author,
ChannelId channelId,
DateTime? uploadDate,
DateTime? publishDate,
String description,
Duration? duration,
ThumbnailSet thumbnails,
UnmodifiableListView<String> keywords,
Engagement engagement,
bool isLive,
@internal WatchPage? watchPage});
@override
$VideoIdCopyWith<$Res> get id;
@override
$ChannelIdCopyWith<$Res> get channelId;
@override
$ThumbnailSetCopyWith<$Res> get thumbnails;
@override
$EngagementCopyWith<$Res> get engagement;
}
/// @nodoc
class __$VideoCopyWithImpl<$Res> extends _$VideoCopyWithImpl<$Res>
implements _$VideoCopyWith<$Res> {
__$VideoCopyWithImpl(_Video _value, $Res Function(_Video) _then)
: super(_value, (v) => _then(v as _Video));
@override
_Video get _value => super._value as _Video;
@override
$Res call({
Object? id = freezed,
Object? title = freezed,
Object? author = freezed,
Object? channelId = freezed,
Object? uploadDate = freezed,
Object? publishDate = freezed,
Object? description = freezed,
Object? duration = freezed,
Object? thumbnails = freezed,
Object? keywords = freezed,
Object? engagement = freezed,
Object? isLive = freezed,
Object? watchPage = freezed,
}) {
return _then(_Video(
id == freezed
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as VideoId,
title == freezed
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
author == freezed
? _value.author
: author // ignore: cast_nullable_to_non_nullable
as String,
channelId == freezed
? _value.channelId
: channelId // ignore: cast_nullable_to_non_nullable
as ChannelId,
uploadDate == freezed
? _value.uploadDate
: uploadDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
publishDate == freezed
? _value.publishDate
: publishDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
description == freezed
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
duration == freezed
? _value.duration
: duration // ignore: cast_nullable_to_non_nullable
as Duration?,
thumbnails == freezed
? _value.thumbnails
: thumbnails // ignore: cast_nullable_to_non_nullable
as ThumbnailSet,
keywords == freezed
? _value.keywords
: keywords // ignore: cast_nullable_to_non_nullable
as UnmodifiableListView<String>,
engagement == freezed
? _value.engagement
: engagement // ignore: cast_nullable_to_non_nullable
as Engagement,
isLive == freezed
? _value.isLive
: isLive // ignore: cast_nullable_to_non_nullable
as bool,
watchPage == freezed
? _value.watchPage
: watchPage // ignore: cast_nullable_to_non_nullable
as WatchPage?,
));
}
}
/// @nodoc
class _$_Video extends _Video {
const _$_Video(
this.id,
this.title,
this.author,
this.channelId,
this.uploadDate,
this.publishDate,
this.description,
this.duration,
this.thumbnails,
this.keywords,
this.engagement,
this.isLive,
[@internal this.watchPage])
: super._();
@override
/// Video ID.
final VideoId id;
@override
/// Video title.
final String title;
@override
/// Video author.
final String author;
@override
/// Video author Id.
final ChannelId channelId;
@override
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
final DateTime? uploadDate;
@override
/// Video publish date.
final DateTime? publishDate;
@override
/// Video description.
final String description;
@override
/// Duration of the video.
final Duration? duration;
@override
/// Available thumbnails for this video.
final ThumbnailSet thumbnails;
@override
/// Search keywords used for this video.
final UnmodifiableListView<String> keywords;
@override
/// Engagement statistics for this video.
final Engagement engagement;
@override
/// Returns true if this is a live stream.
//ignore: avoid_positional_boolean_parameters
final bool isLive;
@override
/// Used internally.
/// Shouldn't be used in the code.
@internal
final WatchPage? watchPage;
@override
String toString() {
return 'Video._internal(id: $id, title: $title, author: $author, channelId: $channelId, uploadDate: $uploadDate, publishDate: $publishDate, description: $description, duration: $duration, thumbnails: $thumbnails, keywords: $keywords, engagement: $engagement, isLive: $isLive, watchPage: $watchPage)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _Video &&
(identical(other.id, id) ||
const DeepCollectionEquality().equals(other.id, id)) &&
(identical(other.title, title) ||
const DeepCollectionEquality().equals(other.title, title)) &&
(identical(other.author, author) ||
const DeepCollectionEquality().equals(other.author, author)) &&
(identical(other.channelId, channelId) ||
const DeepCollectionEquality()
.equals(other.channelId, channelId)) &&
(identical(other.uploadDate, uploadDate) ||
const DeepCollectionEquality()
.equals(other.uploadDate, uploadDate)) &&
(identical(other.publishDate, publishDate) ||
const DeepCollectionEquality()
.equals(other.publishDate, publishDate)) &&
(identical(other.description, description) ||
const DeepCollectionEquality()
.equals(other.description, description)) &&
(identical(other.duration, duration) ||
const DeepCollectionEquality()
.equals(other.duration, duration)) &&
(identical(other.thumbnails, thumbnails) ||
const DeepCollectionEquality()
.equals(other.thumbnails, thumbnails)) &&
(identical(other.keywords, keywords) ||
const DeepCollectionEquality()
.equals(other.keywords, keywords)) &&
(identical(other.engagement, engagement) ||
const DeepCollectionEquality()
.equals(other.engagement, engagement)) &&
(identical(other.isLive, isLive) ||
const DeepCollectionEquality().equals(other.isLive, isLive)) &&
(identical(other.watchPage, watchPage) ||
const DeepCollectionEquality()
.equals(other.watchPage, watchPage)));
}
@override
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(id) ^
const DeepCollectionEquality().hash(title) ^
const DeepCollectionEquality().hash(author) ^
const DeepCollectionEquality().hash(channelId) ^
const DeepCollectionEquality().hash(uploadDate) ^
const DeepCollectionEquality().hash(publishDate) ^
const DeepCollectionEquality().hash(description) ^
const DeepCollectionEquality().hash(duration) ^
const DeepCollectionEquality().hash(thumbnails) ^
const DeepCollectionEquality().hash(keywords) ^
const DeepCollectionEquality().hash(engagement) ^
const DeepCollectionEquality().hash(isLive) ^
const DeepCollectionEquality().hash(watchPage);
@JsonKey(ignore: true)
@override
_$VideoCopyWith<_Video> get copyWith =>
__$VideoCopyWithImpl<_Video>(this, _$identity);
}
abstract class _Video extends Video {
const factory _Video(
VideoId id,
String title,
String author,
ChannelId channelId,
DateTime? uploadDate,
DateTime? publishDate,
String description,
Duration? duration,
ThumbnailSet thumbnails,
UnmodifiableListView<String> keywords,
Engagement engagement,
bool isLive,
[@internal WatchPage? watchPage]) = _$_Video;
const _Video._() : super._();
@override
/// Video ID.
VideoId get id => throw _privateConstructorUsedError;
@override
/// Video title.
String get title => throw _privateConstructorUsedError;
@override
/// Video author.
String get author => throw _privateConstructorUsedError;
@override
/// Video author Id.
ChannelId get channelId => throw _privateConstructorUsedError;
@override
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
DateTime? get uploadDate => throw _privateConstructorUsedError;
@override
/// Video publish date.
DateTime? get publishDate => throw _privateConstructorUsedError;
@override
/// Video description.
String get description => throw _privateConstructorUsedError;
@override
/// Duration of the video.
Duration? get duration => throw _privateConstructorUsedError;
@override
/// Available thumbnails for this video.
ThumbnailSet get thumbnails => throw _privateConstructorUsedError;
@override
/// Search keywords used for this video.
UnmodifiableListView<String> get keywords =>
throw _privateConstructorUsedError;
@override
/// Engagement statistics for this video.
Engagement get engagement => throw _privateConstructorUsedError;
@override
/// Returns true if this is a live stream.
//ignore: avoid_positional_boolean_parameters
bool get isLive => throw _privateConstructorUsedError;
@override
/// Used internally.
/// Shouldn't be used in the code.
@internal
WatchPage? get watchPage => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$VideoCopyWith<_Video> get copyWith => throw _privateConstructorUsedError;
}

View File

@ -1,30 +1,46 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../extensions/helpers_extension.dart';
part 'video_id.freezed.dart';
/// Encapsulates a valid YouTube video ID.
class VideoId with EquatableMixin {
@freezed
class VideoId with _$VideoId {
static final _regMatchExp = RegExp(r'youtube\..+?/watch.*?v=(.*?)(?:&|/|$)');
static final _shortMatchExp = RegExp(r'youtu\.be/(.*?)(?:\?|&|/|$)');
static final _embedMatchExp = RegExp(r'youtube\..+?/embed/(.*?)(?:\?|&|/|$)');
/// ID as string.
final String value;
const VideoId._();
const factory VideoId._internal(
/// ID as string.
String value) = _VideoId;
/// Initializes an instance of [VideoId] with a url or video id.
VideoId(String idOrUrl) : value = parseVideoId(idOrUrl) ?? '' {
if (value.isEmpty) {
factory VideoId(String idOrUrl) {
final id = parseVideoId(idOrUrl);
if (id == null) {
throw ArgumentError.value(
idOrUrl, 'urlOrUrl', 'Invalid YouTube video ID or URL');
}
return VideoId._internal(id);
}
/// Converts [obj] to a [VideoId] by calling .toString on that object.
/// If it is already a [VideoId], [obj] is returned
factory VideoId.fromString(dynamic obj) {
if (obj is VideoId) {
return obj;
}
return VideoId(obj.toString());
}
@override
String toString() => value;
@override
List<Object> get props => [value];
/// Returns true if the given [videoId] is valid.
static bool validateVideoId(String videoId) {
if (videoId.isNullOrWhiteSpace) {
@ -68,13 +84,4 @@ class VideoId with EquatableMixin {
}
return null;
}
/// Converts [obj] to a [VideoId] by calling .toString on that object.
/// If it is already a [VideoId], [obj] is returned
factory VideoId.fromString(dynamic obj) {
if (obj is VideoId) {
return obj;
}
return VideoId(obj.toString());
}
}

View File

@ -0,0 +1,136 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'video_id.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$VideoIdTearOff {
const _$VideoIdTearOff();
_VideoId _internal(String value) {
return _VideoId(
value,
);
}
}
/// @nodoc
const $VideoId = _$VideoIdTearOff();
/// @nodoc
mixin _$VideoId {
/// ID as string.
String get value => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$VideoIdCopyWith<VideoId> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $VideoIdCopyWith<$Res> {
factory $VideoIdCopyWith(VideoId value, $Res Function(VideoId) then) =
_$VideoIdCopyWithImpl<$Res>;
$Res call({String value});
}
/// @nodoc
class _$VideoIdCopyWithImpl<$Res> implements $VideoIdCopyWith<$Res> {
_$VideoIdCopyWithImpl(this._value, this._then);
final VideoId _value;
// ignore: unused_field
final $Res Function(VideoId) _then;
@override
$Res call({
Object? value = freezed,
}) {
return _then(_value.copyWith(
value: value == freezed
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
abstract class _$VideoIdCopyWith<$Res> implements $VideoIdCopyWith<$Res> {
factory _$VideoIdCopyWith(_VideoId value, $Res Function(_VideoId) then) =
__$VideoIdCopyWithImpl<$Res>;
@override
$Res call({String value});
}
/// @nodoc
class __$VideoIdCopyWithImpl<$Res> extends _$VideoIdCopyWithImpl<$Res>
implements _$VideoIdCopyWith<$Res> {
__$VideoIdCopyWithImpl(_VideoId _value, $Res Function(_VideoId) _then)
: super(_value, (v) => _then(v as _VideoId));
@override
_VideoId get _value => super._value as _VideoId;
@override
$Res call({
Object? value = freezed,
}) {
return _then(_VideoId(
value == freezed
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$_VideoId extends _VideoId {
const _$_VideoId(this.value) : super._();
@override
/// ID as string.
final String value;
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _VideoId &&
(identical(other.value, value) ||
const DeepCollectionEquality().equals(other.value, value)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(value);
@JsonKey(ignore: true)
@override
_$VideoIdCopyWith<_VideoId> get copyWith =>
__$VideoIdCopyWithImpl<_VideoId>(this, _$identity);
}
abstract class _VideoId extends VideoId {
const factory _VideoId(String value) = _$_VideoId;
const _VideoId._() : super._();
@override
/// ID as string.
String get value => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$VideoIdCopyWith<_VideoId> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -9,7 +9,7 @@ environment:
dependencies:
collection: ^1.15.0
equatable: ^2.0.0
freezed_annotation: ^0.14.3
html: ^0.15.0
http: ^0.13.0
http_parser: ^4.0.0
@ -18,10 +18,10 @@ dependencies:
xml: ^5.0.2
dev_dependencies:
build_runner: ^1.12.2
console: ^4.0.0
grinder: ^0.9.0-nullsafety.0
json_serializable: ^4.1.0
build_runner: ^2.0.6
console: ^4.1.0
freezed: ^0.14.3
grinder: ^0.9.0
json_serializable: ^5.0.0
lint: ^1.5.3
pedantic: ^1.11.0
test: ^1.16.8
test: ^1.17.10