From 04249eeab3a6e41dc0d75d27dd81e00f15549b33 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Sat, 22 Aug 2020 17:01:33 +0800 Subject: [PATCH] remove MediumType attribute in MediaPage, and remove MediumType parameter in listMedia method --- lib/photo_gallery.dart | 5 ++--- lib/src/models/album.dart | 1 - lib/src/models/media_page.dart | 14 ++------------ 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/photo_gallery.dart b/lib/photo_gallery.dart index 9ae86cf..a8ada82 100644 --- a/lib/photo_gallery.dart +++ b/lib/photo_gallery.dart @@ -35,7 +35,6 @@ class PhotoGallery { static Future _listMedia({ @required Album album, - @required MediumType mediumType, @required int total, int skip, int take, @@ -43,12 +42,12 @@ class PhotoGallery { assert(album.id != null); final json = await _channel.invokeMethod('listMedia', { 'albumId': album.id, - 'mediumType': mediumTypeToJson(mediumType), + 'mediumType': mediumTypeToJson(album.mediumType), 'total': total, 'skip': skip, 'take': take, }); - return MediaPage.fromJson(album, mediumType, json); + return MediaPage.fromJson(album, json); } static Future getMedium({ diff --git a/lib/src/models/album.dart b/lib/src/models/album.dart index 7337c9a..27b9597 100644 --- a/lib/src/models/album.dart +++ b/lib/src/models/album.dart @@ -35,7 +35,6 @@ class Album { }) { return PhotoGallery._listMedia( album: this, - mediumType: this.mediumType, total: this.count, skip: skip, take: take, diff --git a/lib/src/models/media_page.dart b/lib/src/models/media_page.dart index 0f1ae0d..c286dc5 100644 --- a/lib/src/models/media_page.dart +++ b/lib/src/models/media_page.dart @@ -5,9 +5,6 @@ part of photogallery; class MediaPage { final Album album; - /// The medium type of [items]. - final MediumType mediumType; - /// The start offset for those media. final int start; @@ -24,7 +21,7 @@ class MediaPage { bool get isLast => end >= total; /// Creates a range of media from platform channel protocol. - MediaPage.fromJson(this.album, this.mediumType, dynamic json) + MediaPage.fromJson(this.album, dynamic json) : start = json['start'], total = json['total'], items = json['items'].map((x) => Medium.fromJson(x)).toList(); @@ -34,7 +31,6 @@ class MediaPage { assert(!isLast); return PhotoGallery._listMedia( album: album, - mediumType: mediumType, total: total, skip: end, take: items.length, @@ -47,23 +43,17 @@ class MediaPage { other is MediaPage && runtimeType == other.runtimeType && album == other.album && - mediumType == other.mediumType && start == other.start && total == other.total && listEquals(items, other.items); @override int get hashCode => - album.hashCode ^ - mediumType.hashCode ^ - start.hashCode ^ - total.hashCode ^ - items.hashCode; + album.hashCode ^ start.hashCode ^ total.hashCode ^ items.hashCode; @override String toString() { return 'MediaPage{album: $album, ' - 'mediumType: $mediumType, ' 'start: $start, ' 'total: $total, ' 'items: $items}';