flutter_photo_manager icon indicating copy to clipboard operation
flutter_photo_manager copied to clipboard

[Feature] Better way to handle notify

Open bdlukaa opened this issue 4 years ago • 3 comments

Is your feature request related to a problem? Please describe. When I'm trying to update my media grid when the gallery is updated, I have to handle MethodCall by myself. I could figure out how to get the possible values present if call.arguments

https://github.com/fluttercandies/flutter_photo_manager/blob/b6885e31e64ea59032e20e029c840dfbd21e6533/android/src/main/kotlin/top/kikt/imagescanner/core/PhotoManagerNotifyChannel.kt#L73-L77

Which makes me do:

void _onChanged(MethodCall call) {
  final args = call.arguments;
  final path = args['uri'];
  final changeType = args['type'];
  final mediaType = args['mediaType'];
}

Describe the solution you'd like A better way to handle it. Something like:

void _onChanged(MediaChangeInfo info) {
  final path = info.uri;
  final changeType = path.changeType;
  final mediaType = path.mediaType;
}

Or maybe even with streams (a more dart-way):

PhotoManager.onNotify.listen((MediaChangeInfo info) { ... });

Describe alternatives you've considered N/A

Additional context

  • photo_manager version ^1.3.10

bdlukaa avatar Dec 08 '21 14:12 bdlukaa

AFAICT, notify events are different between platforms. https://github.com/fluttercandies/flutter_photo_manager/blob/2ffa0b70926988570520711c3e0292a292041763/ios/Classes/PhotoChangeObserver.m#L35-L37

AlexV525 avatar Dec 08 '21 16:12 AlexV525

Then, another reason to make a unified version and better way to do so in dart

bdlukaa avatar Dec 08 '21 19:12 bdlukaa

The problem is that it is difficult to establish uniformly, because Android's notifications about MediaStore actually change frequently. Since API26(The most major API version when this package was created), there have been 3~4 behavior changes.

Although the behavior of iOS has not changed much in recent versions, due to the introduction of limit permissions, the current notifications are also inaccurate.

Moreover, the recent Android should also introduce the limit read permission of the photo album, and may face the same problem as iOS at that time.

Therefore, the notification function may not be able to bring new features for the time being. I plan to make a modification to the notification system after the Android limit permission is completed.

CaiJingLong avatar Jul 17 '23 07:07 CaiJingLong