Firelands128 / photo_gallery

A Flutter plugin that retrieves images and videos from mobile native gallery.
BSD 3-Clause "New" or "Revised" License
68 stars 62 forks source link

'Newest' parameter does not work on Android 11. #42

Closed pablo-johnson closed 1 year ago

pablo-johnson commented 2 years ago

I always get the oldest photo first when listing the media from an album, no matter if I specify the newest parameter as true or false.

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale en-DE) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Android Studio (version 2020.3) [✓] VS Code (version 1.63.2) [✓] Connected device (1 available)

fn-19 commented 2 years ago

i have this issue but i found this package don't check year of date, for 2021 year worked correctly but 2022 not working how to fixed this issue?

fn-19 commented 2 years ago

I fixed by sort list by this line:

 ////sort new to last
  _media?.sort((a, b) => b.modifiedDate!.compareTo(a.modifiedDate!));
 `MediaPage mediaPage = await widget.album.listMedia(newest: true);

    setState(() {
      _media = mediaPage.items;
      _media?.sort((a, b) => b.modifiedDate!.compareTo(a.modifiedDate!));
    });
pablo-johnson commented 2 years ago

Thank you for your solution. It may work in some cases. In my case, I am also doing pagination so your solution is not suitable. But it may work in case someone does not use pagination.

jhon2307 commented 1 year ago

Hi, do you know if this has been solved yet. Working with paging does not work.

Firelands128 commented 1 year ago

Solved after version 1.2.2. But it's highly recommended to use version 2.0.0 in new projects, because the brand new API can get a better experience.