Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path getter can return null #823

Closed
3 of 4 tasks
zegnus opened this issue Sep 14, 2021 · 2 comments
Closed
3 of 4 tasks

Path getter can return null #823

zegnus opened this issue Sep 14, 2021 · 2 comments
Labels
new issue An issue that hasn't yet been seen from the maintainer

Comments

@zegnus
Copy link

zegnus commented Sep 14, 2021

Describe the bug
The PlatformFile object can be instantiated with a null path:

class PlatformFile {
  PlatformFile({
    String? path,
    required this.name,
    required this.size,
    this.bytes,
    this.readStream,
  }) : _path = path;

But the public method String get path does not allow to return null:

String get path {
    if (kIsWeb) {
      /// https://github.com/miguelpruivo/flutter_file_picker/issues/751
      throw '''
      On web `path` is always `null`,
      You should access `bytes` property instead,
      Read more about it [here](https://github.com/miguelpruivo/flutter_file_picker/wiki/FAQ)
      ''';
    }
    return _path!;
  }

where

    return _path!;

will throw an error

Platform

  • Android
  • iOS
  • Web
  • Desktop (Go)

Platform OS version
This is platform-independent error

Details to reproduce the issue

  1. Instantiate a PlatformFile without providing a path
  2. Access the path
@zegnus zegnus added the new issue An issue that hasn't yet been seen from the maintainer label Sep 14, 2021
@miguelpruivo
Copy link
Owner

Hi, thank you, good catch.

miguelpruivo pushed a commit that referenced this issue Sep 15, 2021
@miguelpruivo
Copy link
Owner

Fixed with 4.0.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new issue An issue that hasn't yet been seen from the maintainer
Projects
None yet
Development

No branches or pull requests

2 participants