add light weight support in Album and MediaPage

This commit is contained in:
Wenqi Li 2023-07-24 00:36:28 +08:00
parent 2db4d8901e
commit 185628470a
2 changed files with 7 additions and 3 deletions

View File

@ -36,11 +36,13 @@ class Album {
Future<MediaPage> listMedia({
int? skip,
int? take,
bool? lightWeight,
}) {
return PhotoGallery._listMedia(
album: this,
skip: skip,
take: take,
lightWeight: lightWeight,
);
}

View File

@ -11,6 +11,8 @@ class MediaPage {
/// The current items.
final List<Medium> 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<Medium>((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() {