miguelpruivo / flutter_file_picker

File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.
MIT License
1.36k stars 676 forks source link

FlieType.audio is - doesn't work #224

Closed ElaineSchwner closed 4 years ago

ElaineSchwner commented 4 years ago

Describe the bug getFile with FileType doesn't work on iOS.

Future getFile() async { File file = await FilePicker.getFile(type: FileType.audio); return file; }

Issue details

  1. iOS The same dode works on Android

Error Log flutter: [FilePicker] Platform exception: PlatformException(multiple_request, Cancelled by a second request, null) 2020-04-03 12:24:20.769179-0300 Runner[767:85752] [VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: PlatformException(multiple_request, Cancelled by a second request, null)

0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569)

1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321)

#2 FilePicker._getPath (package:file_picker/file_picker.dart:56) #3 FilePicker.getFile (package:file_picker/file_picker.dart:41) #4 _AudiosAddState.getFile (package:comunidade/audiosadd.dart:188) #5 _AudiosAddState.buscararquivo (package:comunidade/audiosadd.dart:171) #6 _AudiosAddState.build. (package:comunidade/audiosadd.dart:74) #7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706) #8 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:789) #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182) #10 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486) #11 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282) #12 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199) #13 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:467) #14 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76) #15 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:117) #16 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379) #17 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115) #18 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101) **Flutter Version details** [✓] Flutter (Channel beta, v1.15.17, on Mac OS X 10.15.3 19D76, locale pt-BR)
miguelpruivo commented 4 years ago

Well, the error seems clear here @ElaineSchwner, looks like multiple requests are being made at once.

Could you please try on the plugin's example app? Thank you.

namchuai commented 4 years ago

@miguelpruivo The plugin's example app has the same error.

flutter: [FilePicker] Platform exception: PlatformException(multiple_request, Cancelled by a second request, null) flutter: Unsupported operationPlatformException(multiple_request, Cancelled by a second request, null)

When file type is choosen, for example, from audio. The first click on Open file picker and seems to load forever. The error will be printed out after the second click.

miguelpruivo commented 4 years ago

@namchuai that's actually an error to expect, as you can see in the error description, it was thrown due to a second request being made — when you tap again, which isn't actually supposed.

The FileType.audio opens the music app and won't work on simulator. You need to try on a real device and have in mind that won't let you pick DRM protected files as well.

If you need to pick your own music files, from Files app, for example, just use FileType.custom with allowedExtensions set to something like ['mp3', 'ogg', 'wav'] etc.

namchuai commented 4 years ago

Thanks for very quick reply and clear explaination.

husnain067 commented 3 years ago

thanks for the solution