Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Image Metadata is not returned due to a cast exception #5

Open
aakash-nerurkar opened this issue Jun 28, 2021 · 1 comment
Open

Image Metadata is not returned due to a cast exception #5

aakash-nerurkar opened this issue Jun 28, 2021 · 1 comment

Comments

@aakash-nerurkar
Copy link

Bug Report

multi_image_picker version: ^5.0.2

Is it happening on Android: Yes

Is it happening on iOS: Not tested yet

 C:\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19042.1052], locale en-IN)
    • Flutter version 2.2.2 at C:\flutter
    • Framework revision d79295af24 (2 weeks ago), 2021-06-11 08:56:01 -0700
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Android_SDK
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[√] Connected device (4 available)
    • Redmi 5A (mobile)                  • e9cace177d15  • android-arm64  • Android 8.1.0 (API 27)
    • Android SDK built for x86 (mobile) • emulator-5556 • android-x86    • Android 8.0.0 (API 26) (emulator)
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 90.0.4430.93
    • Edge (web)                         • edge          • web-javascript • Microsoft Edge 91.0.864.59

• No issues found!
Process finished with exit code 0

Describe the bug

Image metadata is never returned due to a cast exception in picker.dart in below function
// Requests image metadata for a given [identifier]
static Future requestMetadata(String? identifier) async {
Map<dynamic, dynamic> map = await (_channel.invokeMethod(
"requestMetadata",
<String, dynamic>{
"identifier": identifier,
},
) as FutureOr<Map<dynamic, dynamic>>);

Map<String, dynamic> metadata = Map<String, dynamic>.from(map);
if (Platform.isIOS) {
  metadata = _normalizeMetadata(metadata);
}

return Metadata.fromMap(metadata);

}

The cast to as FutureOr<Map<dynamic, dynamic>> always returns an error and the metadata is never returned.
Getting the below exception always

E/flutter (22947): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: type 'Future' is not a subtype of type 'FutureOr<Map<dynamic, dynamic>>' in type cast
E/flutter (22947): #0 MultiImagePicker.requestMetadata (package:multi_image_picker2/src/picker.dart:166:7)
E/flutter (22947): #1 Asset.metadata (package:multi_image_picker2/src/asset.dart:136:29)
E/flutter (22947): #2 _MyImagePicker.modList (package:flutter_complete_guide/main.dart:187:37)
E/flutter (22947): #3 _MyImagePicker.loadAssets. (package:flutter_complete_guide/main.dart:180:7)
E/flutter (22947): #4 State.setState (package:flutter/src/widgets/framework.dart:1088:30)
E/flutter (22947): #5 _MyImagePicker.loadAssets (package:flutter_complete_guide/main.dart:177:5)
E/flutter (22947):

My code calling the metadata:
modList(List resultList) async{
for (var x=0 ; x < resultList.length; x++){
Asset asset = resultList[x];
Future meta = asset.metadata;
meta.then((value) => { logLatlong(value)}
);
}
}

logLatlong(Metadata metadata){
print ("Ref Altitud:${metadata.gps.gpsLatitudeRef} Latitud : ${metadata.gps.gpsLatitude}" );
print ("Ref Longitud:${metadata.gps.gpsLongitudeRef} Longitud : ${metadata.gps.gpsLongitude}" );
}

Please help with this issue if possible.
Thanks.

@orliu
Copy link

orliu commented Jul 30, 2021

I got the same issue on iPhone 12 Pro max (iOS: 14.2) simulator.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants