Flutter_file_picker: FlieType.audio is - doesn't work

Created on 3 Apr 2020  Â·  4Comments  Â·  Source: miguelpruivo/flutter_file_picker

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)

awaiting response

Most helpful comment

@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.

All 4 comments

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.

@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.

@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.

Thanks for very quick reply and clear explaination.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

travisjayday picture travisjayday  Â·  7Comments

bkoznov picture bkoznov  Â·  5Comments

zs-dima picture zs-dima  Â·  4Comments

lecicdjuro picture lecicdjuro  Â·  6Comments

hauketoenjes picture hauketoenjes  Â·  6Comments