From 185628470aed23ab1bcbd35caedceacec5f04c48 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Mon, 24 Jul 2023 00:36:28 +0800 Subject: [PATCH] add light weight support in Album and MediaPage --- lib/src/models/album.dart | 2 ++ lib/src/models/media_page.dart | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/src/models/album.dart b/lib/src/models/album.dart index 9e941a3..8248a48 100644 --- a/lib/src/models/album.dart +++ b/lib/src/models/album.dart @@ -36,11 +36,13 @@ class Album { Future listMedia({ int? skip, int? take, + bool? lightWeight, }) { return PhotoGallery._listMedia( album: this, skip: skip, take: take, + lightWeight: lightWeight, ); } diff --git a/lib/src/models/media_page.dart b/lib/src/models/media_page.dart index ab2eaa3..af6c39b 100644 --- a/lib/src/models/media_page.dart +++ b/lib/src/models/media_page.dart @@ -11,6 +11,8 @@ class MediaPage { /// The current items. final List items; + final bool? lightWeight; + /// The end index in the album. int get end => start + items.length; @@ -18,7 +20,7 @@ class MediaPage { bool get isLast => end >= album.count; /// Creates a range of media from platform channel protocol. - MediaPage.fromJson(this.album, dynamic json) + MediaPage.fromJson(this.album, dynamic json, {this.lightWeight}) : start = json['start'] ?? 0, items = json['items'].map((x) => Medium.fromJson(x)).toList(); @@ -29,6 +31,7 @@ class MediaPage { album: album, skip: end, take: items.length, + lightWeight: lightWeight ); } @@ -42,8 +45,7 @@ class MediaPage { listEquals(items, other.items); @override - int get hashCode => - album.hashCode ^ start.hashCode ^ items.hashCode; + int get hashCode => album.hashCode ^ start.hashCode ^ items.hashCode; @override String toString() {