Skip to content

File selector throws exception when closing file chooser without picking any folder #158430

@viseztrance

Description

@viseztrance

What package does this bug report belong to?

file_selector

What target platforms are you seeing this bug on?

Linux

Have you already upgraded your packages?

Yes

Dependency versions

pubspec.lock
  file_selector:
    dependency: "direct main"
    description:
      name: file_selector
      sha256: "5019692b593455127794d5718304ff1ae15447dea286cdda9f0db2a796a1b828"
      url: "https://pub.dev"
    source: hosted
    version: "1.0.3"

Steps to reproduce

  1. Call getDirectoryPath() and close the file chooser without selecting any value.
  2. That's it.

Passing initialDirectory as an argument with an existing location also fails.

getDirectoryPath(initialDirectory: '/home')

Expected results

final value = await getDirectoryPath();

If file chooser is closed without selecting a value, value should be null

Actual results

final value = await getDirectoryPath();

Throws an error, value is never set.

** (meridian-arcade:814059): CRITICAL **: 19:19:17.655: FlValue *fl_value_ref(FlValue *): assertion 'self != nullptr' failed

** (meridian-arcade:814059): CRITICAL **: 19:19:17.655: void fl_value_append_take(FlValue *, FlValue *): assertion 'value != nullptr' failed
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (length): Invalid value: Valid value range is empty: 0
#0      _Array.[] (dart:core-patch/array.dart)
#1      FileSelectorApi.showFileChooser (package:file_selector_linux/src/messages.g.dart:186:35)
<asynchronous suspension>
#2      FileSelectorLinux.getDirectoryPath (package:file_selector_linux/file_selector_linux.dart:101:32)
<asynchronous suspension>

Code sample

Code sample
getDirectoryPath();
// Don't select any location, just close window directly

Screenshots or Videos

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.4, on Ubuntu 24.04.1 LTS 6.8.0-47-generic, locale en_US.UTF-8)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✗] 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
[!] Android Studio (not installed)
[✓] Connected device (1 available)
[✓] Network resources

! Doctor found issues in 3 categories.

Metadata

Metadata

Labels

c: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowfound in release: 3.24Found to occur in 3.24fyi-ecosystemFor the attention of Ecosystem teamhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: file_selectorThe file_selector pluginpackageflutter/packages repository. See also p: labels.platform-linuxBuilding on or for Linux specificallyr: fixedIssue is closed as already fixed in a newer versionteam-linuxOwned by the Linux platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions