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.35k stars 675 forks source link

Crashing on incomplete saveFile() #1523

Open timoxd7 opened 5 months ago

timoxd7 commented 5 months ago

Describe the bug Invoking saveFile() without filename or without bytes parameter will crash the app silently.

Platform

Platform OS version 17.5

How are you picking?

// Working:
outputFile = await FilePicker.platform.saveFile(
  dialogTitle: 'Please select an output file:',
  fileName: 'file.txt',
  type: FileType.any,
  bytes: Uint8List(0),
);

// Not working:
outputFile = await FilePicker.platform.saveFile(
  dialogTitle: 'Please select an output file:',
  fileName: 'log.txt',
  type: FileType.any,
);

outputFile = await FilePicker.platform.saveFile(
  dialogTitle: 'Please select an output file:',
  type: FileType.any,
  bytes: Uint8List(0),
);

Details to reproduce the issue Use code provided above

Error Log None, will crash at FilePickerPlugin.m:181 if no file name is provided for example.

Flutter Version details [✓] Flutter (Channel stable, 3.22.1, on macOS 14.5 23F79 darwin-arm64, locale de-DE) • Flutter version 3.22.1 on channel stable at /Users/timo/sdk/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision a14f74ff3a (13 days ago), 2024-05-22 11:08:21 -0500 • Engine revision 55eae6864b • Dart version 3.4.1 • DevTools version 2.34.3

Additional context file_picker version 8.0.3

sotowang commented 3 months ago

i got the same issue on android

xiaoqiaowoai commented 3 months ago

I got the same problem on an ios iPad.

vargab95 commented 3 weeks ago

I got the same on android. Using the "bytes: Uint8List(0)," workaround now.