miguelpruivo/flutter_file_picker

unable to pick files on Ubuntu 22.04.2 desktop

AbikMathew opened this issue · 3 comments

The issue
I tried to use the flutter_file_picker package to pick some files on my ubuntu laptop and it is not working. So I went onto try the example app from the github repo and the same issue occurs with that one also. When we call the method to pick files, dialog box won't appear.

Platform

  • Desktop

Platform OS version
Ubuntu 22.04.02

How are you picking?

  void _pickFiles() async {
    _resetState();
    try {
      _directoryPath = null;
      _paths = (await FilePicker.platform.pickFiles(
        type: _pickingType,
        allowMultiple: _multiPick,
        onFileLoading: (FilePickerStatus status) => print(status),
        allowedExtensions: (_extension?.isNotEmpty ?? false)
            ? _extension?.replaceAll(' ', '').split(',')
            : null,
        dialogTitle: _dialogTitleController.text,
        initialDirectory: _initialDirectoryController.text,
        lockParentWindow: _lockParentWindow,
      ))
          ?.files;
    } on PlatformException catch (e) {
      _logException('Unsupported operation' + e.toString());
    } catch (e) {
      _logException(e.toString());
    }
    if (!mounted) return;
    setState(() {
      _isLoading = false;
      _fileName =
          _paths != null ? _paths!.map((e) => e.name).toString() : '...';
      _userAborted = _paths == null;
    });
  }

Details to reproduce the issue
Just run the example app on an ubuntu 22.04 machine, and you won't be able to pick any files.

Error Log
There are no errors or exceptions caught

Screenshots and/or video
image

Flutter Version details
[!] Flutter (Channel unknown, 3.7.7, on Ubuntu 22.04.2 LTS 5.19.0-40-generic, locale en_US.UTF-8)
! Flutter version 3.7.7 on channel unknown

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /home/abik/Android/Sdk
• Platform android-33-ext5, build-tools 33.0.2
• Java binary at: /snap/android-studio/125/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop
• Ubuntu clang version 14.0.0-1ubuntu1
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2

[✓] Android Studio (version 2021.3)
• Android Studio at /snap/android-studio/125/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.13+0-b1751.21-8125866)

[✓] VS Code
• VS Code at /snap/code/current
• Flutter extension version 3.62.0

[✓] Connected device (1 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.2 LTS 5.19.0-40-generic

[✓] HTTP Host Availability
• All required HTTP hosts are available

Hey, I was going to create a new issue but it likely is easier to just hijack this one since it's related anyway.

Basically, the file_picker plugin relies on one of these command being available: qarma, zenity or kdialog. As far as I understand it uses them to create a very generic dialog:

/// Returns the path to the executables `qarma`, `zenity` or `kdialog` as a
/// [String].
/// On Linux, the CLI tools `qarma` or `zenity` can be used to open a native
/// file picker dialog. It seems as if all Linux distributions have at least
/// one of these two tools pre-installed (on Ubuntu `zenity` is pre-installed).
/// On distribuitions that use KDE Plasma as their Desktop Environment,
/// `kdialog` is used to achieve these functionalities.
/// The future returns an error, if none of the executables was found on
/// the path.
Future<String> _getPathToExecutable() async {
try {
try {
return await isExecutableOnPath('qarma');
} on Exception {
return await isExecutableOnPath('kdialog');
}
} on Exception {
return await isExecutableOnPath('zenity');
}
}

It seems the plugin relied on zenity being pre-installed and working, and that might not be true on your system.


IMHO, using those generic dialogs is not the best way to achieve a file picker.
Linux has been standardizing some features recently and there's a File Chooser XDG Portal which can be used with native integration with the user system as well as working very well inside sandboxes (since they were created to work in them).

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

This issue was closed because it has been inactive for 14 days since being marked as stale.