Implement Equatable
This commit is contained in:
parent
47be25b85c
commit
12cbc41b6d
|
@ -5,9 +5,14 @@ include: package:effective_dart/analysis_options.yaml
|
||||||
|
|
||||||
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
|
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
|
||||||
# Uncomment to specify additional rules.
|
# Uncomment to specify additional rules.
|
||||||
# linter:
|
linter:
|
||||||
# rules:
|
rules:
|
||||||
# - camel_case_types
|
- valid_regexps
|
||||||
|
- prefer_const_constructors
|
||||||
|
- prefer_const_declarations
|
||||||
|
- prefer_const_literals_to_create_immutables
|
||||||
|
- prefer_constructors_over_static_methods
|
||||||
|
- prefer_contains
|
||||||
|
|
||||||
analyzer:
|
analyzer:
|
||||||
# exclude:
|
# exclude:
|
||||||
|
|
|
@ -9,7 +9,10 @@ class AudioStreamInfo extends MediaStreamInfo {
|
||||||
final AudioEncoding audioEncoding;
|
final AudioEncoding audioEncoding;
|
||||||
|
|
||||||
/// Initializes an instance of [AudioStreamInfo]
|
/// Initializes an instance of [AudioStreamInfo]
|
||||||
const AudioStreamInfo(int tag, Uri url, Container container, int size,
|
AudioStreamInfo(int tag, Uri url, Container container, int size, this.bitrate,
|
||||||
this.bitrate, this.audioEncoding)
|
this.audioEncoding)
|
||||||
: super(tag, url, container, size);
|
: super(tag, url, container, size);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => super.props..addAll([bitrate, audioEncoding]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
/// Information about a YouTube channel.
|
/// Information about a YouTube channel.
|
||||||
class Channel {
|
class Channel extends Equatable {
|
||||||
/// ID of this channel.
|
/// ID of this channel.
|
||||||
final String id;
|
final String id;
|
||||||
|
|
||||||
|
@ -10,5 +12,8 @@ class Channel {
|
||||||
final Uri logoUrl;
|
final Uri logoUrl;
|
||||||
|
|
||||||
/// Initializes an instance of [Channel]
|
/// Initializes an instance of [Channel]
|
||||||
Channel(this.id, this.title, this.logoUrl);
|
const Channel(this.id, this.title, this.logoUrl);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [id, title, logoUrl];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/// Text that gets displayed at specific time during video playback, as part of a <see cref="ClosedCaptionTrack"/>.
|
import 'package:equatable/equatable.dart';
|
||||||
class ClosedCaption {
|
|
||||||
|
/// Text that gets displayed at specific time during video playback,
|
||||||
|
/// as part of a [ClosedCaptionTrack]
|
||||||
|
class ClosedCaption extends Equatable {
|
||||||
/// Text displayed by this caption.
|
/// Text displayed by this caption.
|
||||||
final String text;
|
final String text;
|
||||||
|
|
||||||
|
@ -21,4 +24,7 @@ class ClosedCaption {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'Caption: $text ($offset - $end)';
|
String toString() => 'Caption: $text ($offset - $end)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [text, offset, duration];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
import 'models.dart';
|
import 'models.dart';
|
||||||
|
|
||||||
/// Set of captions that get displayed during video playback.
|
/// Set of captions that get displayed during video playback.
|
||||||
class ClosedCaptionTrack {
|
class ClosedCaptionTrack extends Equatable {
|
||||||
/// Metadata associated with this track.
|
/// Metadata associated with this track.
|
||||||
final ClosedCaptionTrackInfo info;
|
final ClosedCaptionTrackInfo info;
|
||||||
|
|
||||||
|
@ -10,4 +12,7 @@ class ClosedCaptionTrack {
|
||||||
|
|
||||||
/// Initializes an instance of [ClosedCaptionTrack]
|
/// Initializes an instance of [ClosedCaptionTrack]
|
||||||
const ClosedCaptionTrack(this.info, this.captions);
|
const ClosedCaptionTrack(this.info, this.captions);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [info, captions];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
import 'models.dart';
|
import 'models.dart';
|
||||||
|
|
||||||
/// Metadata associated with a certain [ClosedCaptionTrack]
|
/// Metadata associated with a certain [ClosedCaptionTrack]
|
||||||
class ClosedCaptionTrackInfo {
|
class ClosedCaptionTrackInfo extends Equatable {
|
||||||
/// Manifest URL of the associated track.
|
/// Manifest URL of the associated track.
|
||||||
final Uri url;
|
final Uri url;
|
||||||
|
|
||||||
|
@ -13,4 +15,7 @@ class ClosedCaptionTrackInfo {
|
||||||
|
|
||||||
/// Initializes an instance of [ClosedCaptionTrackInfo]
|
/// Initializes an instance of [ClosedCaptionTrackInfo]
|
||||||
const ClosedCaptionTrackInfo(this.url, this.language, {this.isAutoGenerated});
|
const ClosedCaptionTrackInfo(this.url, this.language, {this.isAutoGenerated});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [url, language, isAutoGenerated];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
/// Language information.
|
/// Language information.
|
||||||
class Language {
|
class Language extends Equatable {
|
||||||
/// ISO 639-1 code of this language.
|
/// ISO 639-1 code of this language.
|
||||||
final String code;
|
final String code;
|
||||||
|
|
||||||
|
@ -8,4 +10,7 @@ class Language {
|
||||||
|
|
||||||
/// Initializes an instance of [Language]
|
/// Initializes an instance of [Language]
|
||||||
const Language(this.code, this.name);
|
const Language(this.code, this.name);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [code, name];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
import 'models.dart';
|
import 'models.dart';
|
||||||
|
|
||||||
/// Metadata associated with a certain [MediaStream]
|
/// Metadata associated with a certain [MediaStream]
|
||||||
class MediaStreamInfo {
|
class MediaStreamInfo extends Equatable {
|
||||||
/// Unique tag that identifies the properties of the associated stream.
|
/// Unique tag that identifies the properties of the associated stream.
|
||||||
final int itag;
|
final int itag;
|
||||||
|
|
||||||
|
@ -19,4 +21,7 @@ class MediaStreamInfo {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$itag ($container)';
|
String toString() => '$itag ($container)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [itag, url, container, size];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
import 'models.dart';
|
import 'models.dart';
|
||||||
|
|
||||||
/// Set of all available media stream infos.
|
/// Set of all available media stream infos.
|
||||||
class MediaStreamInfoSet {
|
class MediaStreamInfoSet extends Equatable {
|
||||||
/// Muxed streams.
|
/// Muxed streams.
|
||||||
final List<MuxedStreamInfo> muxed;
|
final List<MuxedStreamInfo> muxed;
|
||||||
|
|
||||||
|
@ -25,4 +27,8 @@ class MediaStreamInfoSet {
|
||||||
/// Initializes an instance of [MediaStreamInfoSet].
|
/// Initializes an instance of [MediaStreamInfoSet].
|
||||||
const MediaStreamInfoSet(this.muxed, this.audio, this.video,
|
const MediaStreamInfoSet(this.muxed, this.audio, this.video,
|
||||||
this.hlsLiveStreamUrl, this.videoDetails, this.validUntil);
|
this.hlsLiveStreamUrl, this.videoDetails, this.validUntil);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props =>
|
||||||
|
[muxed, audio, video, hlsLiveStreamUrl, videoDetails, validUntil];
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class MuxedStreamInfo extends MediaStreamInfo {
|
||||||
|
|
||||||
/// Initializes an instance of [MuxedStreamInfo]
|
/// Initializes an instance of [MuxedStreamInfo]
|
||||||
const MuxedStreamInfo(
|
const MuxedStreamInfo(
|
||||||
int tag,
|
int itag,
|
||||||
Uri url,
|
Uri url,
|
||||||
Container container,
|
Container container,
|
||||||
int size,
|
int size,
|
||||||
|
@ -29,5 +29,15 @@ class MuxedStreamInfo extends MediaStreamInfo {
|
||||||
this.videoQualityLabel,
|
this.videoQualityLabel,
|
||||||
this.videoQuality,
|
this.videoQuality,
|
||||||
this.videoResolution)
|
this.videoResolution)
|
||||||
: super(tag, url, container, size);
|
: super(itag, url, container, size);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => super.props
|
||||||
|
..addAll([
|
||||||
|
audioEncoding,
|
||||||
|
videoEncoding,
|
||||||
|
videoQualityLabel,
|
||||||
|
videoQuality,
|
||||||
|
videoResolution
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
import 'models.dart';
|
import 'models.dart';
|
||||||
|
|
||||||
/// Player configuration.
|
/// Player configuration.
|
||||||
class PlayerConfiguration {
|
class PlayerConfiguration extends Equatable {
|
||||||
/// Player source url.
|
/// Player source url.
|
||||||
final String playerSourceUrl;
|
final String playerSourceUrl;
|
||||||
|
|
||||||
|
@ -40,4 +42,17 @@ class PlayerConfiguration {
|
||||||
this.adaptiveStreamInfosJson,
|
this.adaptiveStreamInfosJson,
|
||||||
this.video,
|
this.video,
|
||||||
this.validUntil);
|
this.validUntil);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [
|
||||||
|
playerSourceUrl,
|
||||||
|
dashManifestUrl,
|
||||||
|
hlsManifestUrl,
|
||||||
|
muxedStreamInfosUrlEncoded,
|
||||||
|
adaptiveStreamInfosUrlEncoded,
|
||||||
|
muxedStreamInfoJson,
|
||||||
|
adaptiveStreamInfosJson,
|
||||||
|
video,
|
||||||
|
validUntil
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
import 'models.dart';
|
import 'models.dart';
|
||||||
|
|
||||||
/// Information about a YouTube playlist.
|
/// Information about a YouTube playlist.
|
||||||
class Playlist {
|
class Playlist extends Equatable {
|
||||||
/// ID of this playlist.
|
/// ID of this playlist.
|
||||||
final String id;
|
final String id;
|
||||||
|
|
||||||
|
@ -26,4 +28,8 @@ class Playlist {
|
||||||
/// Initializes an instance of [Playlist]
|
/// Initializes an instance of [Playlist]
|
||||||
Playlist(this.id, this.author, this.title, this.type, this.description,
|
Playlist(this.id, this.author, this.title, this.type, this.description,
|
||||||
this.statistics, this.videos);
|
this.statistics, this.videos);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props =>
|
||||||
|
[id, author, title, type, description, statistics, videos];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
/// User activity statistics.
|
/// User activity statistics.
|
||||||
class Statistics {
|
class Statistics extends Equatable {
|
||||||
/// View count.
|
/// View count.
|
||||||
final int viewCount;
|
final int viewCount;
|
||||||
|
|
||||||
|
@ -9,7 +11,7 @@ class Statistics {
|
||||||
/// Dislike count.
|
/// Dislike count.
|
||||||
final int dislikeCount;
|
final int dislikeCount;
|
||||||
|
|
||||||
/// Initializes an instance of <see cref="Statistics"/>.
|
/// Initializes an instance of [Statistics]
|
||||||
const Statistics(this.viewCount, this.likeCount, this.dislikeCount);
|
const Statistics(this.viewCount, this.likeCount, this.dislikeCount);
|
||||||
|
|
||||||
/// Average user rating in stars (1 star to 5 stars).
|
/// Average user rating in stars (1 star to 5 stars).
|
||||||
|
@ -19,4 +21,7 @@ class Statistics {
|
||||||
}
|
}
|
||||||
return 1 + 4.0 * likeCount / (likeCount + dislikeCount);
|
return 1 + 4.0 * likeCount / (likeCount + dislikeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [viewCount, likeCount, dislikeCount];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
/// Set of thumbnails for a video.
|
/// Set of thumbnails for a video.
|
||||||
class ThumbnailSet {
|
class ThumbnailSet extends Equatable {
|
||||||
/// Video id.
|
/// Video id.
|
||||||
final String videoId;
|
final String videoId;
|
||||||
|
|
||||||
|
@ -25,4 +27,7 @@ class ThumbnailSet {
|
||||||
/// Not always available.
|
/// Not always available.
|
||||||
String get maxResUrl =>
|
String get maxResUrl =>
|
||||||
'https://img.youtube.com/vi/$videoId/maxresdefault.jpg';
|
'https://img.youtube.com/vi/$videoId/maxresdefault.jpg';
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [videoId];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
import 'models.dart';
|
import 'models.dart';
|
||||||
|
|
||||||
/// Information about a YouTube video.
|
/// Information about a YouTube video.
|
||||||
class Video {
|
class Video extends Equatable {
|
||||||
/// ID of this video.
|
/// ID of this video.
|
||||||
final String id;
|
final String id;
|
||||||
|
|
||||||
|
@ -43,4 +45,17 @@ class Video {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'Video($id): $title';
|
String toString() => 'Video($id): $title';
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [
|
||||||
|
id,
|
||||||
|
author,
|
||||||
|
uploadDate,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
thumbnailSet,
|
||||||
|
duration,
|
||||||
|
keyWords,
|
||||||
|
statistics
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
/// Width and height of a video.
|
/// Width and height of a video.
|
||||||
class VideoResolution {
|
class VideoResolution extends Equatable{
|
||||||
/// Viewport width.
|
/// Viewport width.
|
||||||
final int width;
|
final int width;
|
||||||
|
|
||||||
|
@ -11,4 +13,7 @@ class VideoResolution {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '${width}x$height';
|
String toString() => '${width}x$height';
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [width, height];
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class VideoStreamInfo extends MediaStreamInfo {
|
||||||
|
|
||||||
/// Initializes an instance of [VideoStreamInfo]
|
/// Initializes an instance of [VideoStreamInfo]
|
||||||
const VideoStreamInfo(
|
const VideoStreamInfo(
|
||||||
int tag,
|
int itag,
|
||||||
Uri url,
|
Uri url,
|
||||||
Container container,
|
Container container,
|
||||||
int size,
|
int size,
|
||||||
|
@ -32,5 +32,16 @@ class VideoStreamInfo extends MediaStreamInfo {
|
||||||
this.videoQuality,
|
this.videoQuality,
|
||||||
this.videoResolution,
|
this.videoResolution,
|
||||||
this.framerate)
|
this.framerate)
|
||||||
: super(tag, url, container, size);
|
: super(itag, url, container, size);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => super.props
|
||||||
|
..addAll([
|
||||||
|
bitrate,
|
||||||
|
videoEncoding,
|
||||||
|
videoQualityLabel,
|
||||||
|
videoQuality,
|
||||||
|
videoResolution,
|
||||||
|
framerate
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ dependencies:
|
||||||
http: ^0.12.0+4
|
http: ^0.12.0+4
|
||||||
http_parser: ^3.1.3
|
http_parser: ^3.1.3
|
||||||
xml: ^3.7.0
|
xml: ^3.7.0
|
||||||
|
equatable: ^1.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
effective_dart: ^1.2.1
|
effective_dart: ^1.2.1
|
||||||
|
|
Loading…
Reference in New Issue