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.
|
||||
# Uncomment to specify additional rules.
|
||||
# linter:
|
||||
# rules:
|
||||
# - camel_case_types
|
||||
linter:
|
||||
rules:
|
||||
- valid_regexps
|
||||
- prefer_const_constructors
|
||||
- prefer_const_declarations
|
||||
- prefer_const_literals_to_create_immutables
|
||||
- prefer_constructors_over_static_methods
|
||||
- prefer_contains
|
||||
|
||||
analyzer:
|
||||
# exclude:
|
||||
|
|
|
@ -9,7 +9,10 @@ class AudioStreamInfo extends MediaStreamInfo {
|
|||
final AudioEncoding audioEncoding;
|
||||
|
||||
/// Initializes an instance of [AudioStreamInfo]
|
||||
const AudioStreamInfo(int tag, Uri url, Container container, int size,
|
||||
this.bitrate, this.audioEncoding)
|
||||
AudioStreamInfo(int tag, Uri url, Container container, int size, this.bitrate,
|
||||
this.audioEncoding)
|
||||
: 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.
|
||||
class Channel {
|
||||
class Channel extends Equatable {
|
||||
/// ID of this channel.
|
||||
final String id;
|
||||
|
||||
|
@ -10,5 +12,8 @@ class Channel {
|
|||
final Uri logoUrl;
|
||||
|
||||
/// 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"/>.
|
||||
class ClosedCaption {
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Text that gets displayed at specific time during video playback,
|
||||
/// as part of a [ClosedCaptionTrack]
|
||||
class ClosedCaption extends Equatable {
|
||||
/// Text displayed by this caption.
|
||||
final String text;
|
||||
|
||||
|
@ -21,4 +24,7 @@ class ClosedCaption {
|
|||
|
||||
@override
|
||||
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';
|
||||
|
||||
/// Set of captions that get displayed during video playback.
|
||||
class ClosedCaptionTrack {
|
||||
class ClosedCaptionTrack extends Equatable {
|
||||
/// Metadata associated with this track.
|
||||
final ClosedCaptionTrackInfo info;
|
||||
|
||||
|
@ -10,4 +12,7 @@ class ClosedCaptionTrack {
|
|||
|
||||
/// Initializes an instance of [ClosedCaptionTrack]
|
||||
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';
|
||||
|
||||
/// Metadata associated with a certain [ClosedCaptionTrack]
|
||||
class ClosedCaptionTrackInfo {
|
||||
class ClosedCaptionTrackInfo extends Equatable {
|
||||
/// Manifest URL of the associated track.
|
||||
final Uri url;
|
||||
|
||||
|
@ -13,4 +15,7 @@ class ClosedCaptionTrackInfo {
|
|||
|
||||
/// Initializes an instance of [ClosedCaptionTrackInfo]
|
||||
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.
|
||||
class Language {
|
||||
class Language extends Equatable {
|
||||
/// ISO 639-1 code of this language.
|
||||
final String code;
|
||||
|
||||
|
@ -8,4 +10,7 @@ class Language {
|
|||
|
||||
/// Initializes an instance of [Language]
|
||||
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';
|
||||
|
||||
/// Metadata associated with a certain [MediaStream]
|
||||
class MediaStreamInfo {
|
||||
class MediaStreamInfo extends Equatable {
|
||||
/// Unique tag that identifies the properties of the associated stream.
|
||||
final int itag;
|
||||
|
||||
|
@ -19,4 +21,7 @@ class MediaStreamInfo {
|
|||
|
||||
@override
|
||||
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';
|
||||
|
||||
/// Set of all available media stream infos.
|
||||
class MediaStreamInfoSet {
|
||||
class MediaStreamInfoSet extends Equatable {
|
||||
/// Muxed streams.
|
||||
final List<MuxedStreamInfo> muxed;
|
||||
|
||||
|
@ -25,4 +27,8 @@ class MediaStreamInfoSet {
|
|||
/// Initializes an instance of [MediaStreamInfoSet].
|
||||
const MediaStreamInfoSet(this.muxed, this.audio, this.video,
|
||||
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]
|
||||
const MuxedStreamInfo(
|
||||
int tag,
|
||||
int itag,
|
||||
Uri url,
|
||||
Container container,
|
||||
int size,
|
||||
|
@ -29,5 +29,15 @@ class MuxedStreamInfo extends MediaStreamInfo {
|
|||
this.videoQualityLabel,
|
||||
this.videoQuality,
|
||||
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';
|
||||
|
||||
/// Player configuration.
|
||||
class PlayerConfiguration {
|
||||
class PlayerConfiguration extends Equatable {
|
||||
/// Player source url.
|
||||
final String playerSourceUrl;
|
||||
|
||||
|
@ -40,4 +42,17 @@ class PlayerConfiguration {
|
|||
this.adaptiveStreamInfosJson,
|
||||
this.video,
|
||||
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';
|
||||
|
||||
/// Information about a YouTube playlist.
|
||||
class Playlist {
|
||||
class Playlist extends Equatable {
|
||||
/// ID of this playlist.
|
||||
final String id;
|
||||
|
||||
|
@ -26,4 +28,8 @@ class Playlist {
|
|||
/// Initializes an instance of [Playlist]
|
||||
Playlist(this.id, this.author, this.title, this.type, this.description,
|
||||
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.
|
||||
class Statistics {
|
||||
class Statistics extends Equatable {
|
||||
/// View count.
|
||||
final int viewCount;
|
||||
|
||||
|
@ -9,7 +11,7 @@ class Statistics {
|
|||
/// Dislike count.
|
||||
final int dislikeCount;
|
||||
|
||||
/// Initializes an instance of <see cref="Statistics"/>.
|
||||
/// Initializes an instance of [Statistics]
|
||||
const Statistics(this.viewCount, this.likeCount, this.dislikeCount);
|
||||
|
||||
/// Average user rating in stars (1 star to 5 stars).
|
||||
|
@ -19,4 +21,7 @@ class Statistics {
|
|||
}
|
||||
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.
|
||||
class ThumbnailSet {
|
||||
class ThumbnailSet extends Equatable {
|
||||
/// Video id.
|
||||
final String videoId;
|
||||
|
||||
|
@ -25,4 +27,7 @@ class ThumbnailSet {
|
|||
/// Not always available.
|
||||
String get maxResUrl =>
|
||||
'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';
|
||||
|
||||
/// Information about a YouTube video.
|
||||
class Video {
|
||||
class Video extends Equatable {
|
||||
/// ID of this video.
|
||||
final String id;
|
||||
|
||||
|
@ -43,4 +45,17 @@ class Video {
|
|||
|
||||
@override
|
||||
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.
|
||||
class VideoResolution {
|
||||
class VideoResolution extends Equatable{
|
||||
/// Viewport width.
|
||||
final int width;
|
||||
|
||||
|
@ -11,4 +13,7 @@ class VideoResolution {
|
|||
|
||||
@override
|
||||
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]
|
||||
const VideoStreamInfo(
|
||||
int tag,
|
||||
int itag,
|
||||
Uri url,
|
||||
Container container,
|
||||
int size,
|
||||
|
@ -32,5 +32,16 @@ class VideoStreamInfo extends MediaStreamInfo {
|
|||
this.videoQuality,
|
||||
this.videoResolution,
|
||||
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_parser: ^3.1.3
|
||||
xml: ^3.7.0
|
||||
equatable: ^1.1.0
|
||||
|
||||
dev_dependencies:
|
||||
effective_dart: ^1.2.1
|
||||
|
|
Loading…
Reference in New Issue