fluttercandies / flutter_photo_manager

A Flutter plugin that provides images, videos, and audio abstraction management APIs without interface integration, available on Android, iOS, macOS and OpenHarmony.
https://pub.dev/packages/photo_manager
Apache License 2.0
647 stars 297 forks source link

[Bug report] How do you update the cache? #1102

Closed YesThatGy closed 2 months ago

YesThatGy commented 2 months ago

Version

3.0.1

Platforms

Android

Device Model

Moto Razr + 2023

flutter info

[bens@tesla example]$ flutter doctor -v 
[✓] Flutter (Channel stable, 3.16.5, on Fedora Linux 39 (KDE Plasma) 6.7.9-200.fc39.x86_64, locale
    en_US.UTF-8)
    • Flutter version 3.16.5 on channel stable at /home/bens/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 78666c8dc5 (3 months ago), 2023-12-19 16:14:14 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/bens/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /home/bens/bin/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 17.0.6 (Fedora 17.0.6-2.fc39)
    • cmake version 3.27.7
    • ninja version 1.11.1
    • pkg-config version 1.9.5

[✓] Android Studio (version 2023.1)
    • Android Studio at /home/bens/bin/android-studio
    • Flutter plugin version 77.1.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] Connected device (3 available)
    • motorola razr plus 2023 (mobile) • ZY22HHG5HC • android-arm64  • Android 13 (API 33)
    • Linux (desktop)                  • linux      • linux-x64      • Fedora Linux 39 (KDE Plasma)
      6.7.9-200.fc39.x86_64
    • Chrome (web)                     • chrome     • web-javascript • Google Chrome 122.0.6261.128

[✓] Network resources
    • All expected network resources are available.

• No issues found!

How to reproduce?

I am starting with the example app. I do the following:

1) Run the example app: a) run _requestAssets() b) View the list of pictures

2) Switch to camera a) take a picture  

3) Switch back to the example app a) run _requestAssets() b) The list of pictures does not include the new picture c) EXPECTED: new picture shows. (it does not)

4) restart the example app a) New picture now shows.

I've tried adding a call at the top of _uploadAssets() to PhotoManager.clearFileCache(); and it had no effect.

Logs

No response

Example code (optional)

No response

Contact

yesthatguy@gmail.com

YesThatGy commented 2 months ago

What information can I provide that you might find useful? EG: logs of what?

CaiJingLong commented 2 months ago

In use, because it is considered that re-inserting pictures will cause paging confusion, the FilterOptionGroup in the example will include the update time to ensure that without deleting the picture, the new picture will not affect the list paging of the old path. If you want the latest image to be loaded on each click, you need to use the new _filterOptionGroup in the _requestAssets method in the demo.


final filterOptionGroup = FilterOptionGroup(
    imageOption: const FilterOption(
      sizeConstraint: SizeConstraint(ignoreSize: true),
    ),
  );

final List<AssetPathEntity> paths = await PhotoManager.getAssetPathList(
      onlyAll: true,
      filterOption: _filterOptionGroup,
);