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.3k stars 648 forks source link

FilePicker extension Flutter problem with audio types #1547

Closed faci closed 1 month ago

faci commented 1 month ago

Describe the bug I use the file_picker package (last actual version : 8.0.6) to get audio files on IOS. It works pretty well, but just not on the first load.. On the first load, it asks for apple music access and than when I select a file, the bytes attribute is empty. When I close and re-open it works.

Platform

Platform OS version IOS 17.5.1 -> I had the same problem in the previous versions

How are you picking?

  // Opens the file explorer of the device,
  static Future<FilePickerResult?> getFilePickerFromDevice() async {
    return await FilePicker.platform.pickFiles(
      withData: true,
      type: FileType.audio,
      allowMultiple: false,
      allowCompression: true,
    );
  }
}

I have the authorizations on the info.plist !

<key>NSAppleMusicUsageDescription</key>
<string>Autorisez l'accès à votre musique pour pouvoir la partager.</string>

And I tried to add PERMISSION_MEDIA_LIBRARY in the Podfile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0.0'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',
        'PERMISSION_PHOTOS=1',
        'BYPASS_PERMISSION_LOCATION_ALWAYS=1',
        'PERMISSION_MEDIA_LIBRARY=0'
      ]
    end
  end
end

Details to reproduce the issue Just call the code above ! Make sure you didn't accept the apple music before.

Error Log returned value on the first selection: FilePickerResult(files: [PlatformFile(path /private/var/mobile/Containers/Data/Application/356AB0F5-BFFC-4CE6-82FC-CF94BA1070E9/tmp/Danyl - Billie Eilish (clip officiel).m4a, name: Danyl - Billie Eilish (clip officiel).m4a, bytes: null, readStream: null, size: 0)])

error: (-11850) Opération interrompue

Flutter Version details flutter doctor -v :

[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64 (Rosetta), locale
    fr-FR)
    • Flutter version 3.22.2 on channel stable at /Users/lisafaci/development_tool/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (5 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/lisafaci/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/lisafaci/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google
    Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 17.0.10+0-17.0.10b1087.21-11609105)

[✓] VS Code (version 1.90.2)
    • VS Code at /Users/lisafaci/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.92.0

[✓] Connected device (3 available)
    • iPhone de Lisa (mobile)         • 00008101-000C2D5A1EE0001E • ios          • iOS 17.5.1
      21F90
    • macOS (desktop)                 • macos                     • darwin-arm64 • macOS 14.5
      23F79 darwin-arm64 (Rosetta)
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin       • macOS 14.5
      23F79 darwin-arm64 (Rosetta)

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

! Doctor found issues in 1 category.

More details When I use a FileType.custom and define the types of music I accept, it works, but it opens the normal file storage, while I really need to open apple Music selector, since the app I'm developing is mainly focus on music.

I hope you have enough informations ! And the bug is clear ! thank you :)

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 7 days with no activity.

faci commented 1 month ago

For your info on this issue, the problem seemed to come from FileType: Audio on the filePicker package ! So I just changed to custom. But I believe it's too bad, because that would be nice to be able to use this option on IOS and it works everytime ^^