From 8be4e150d7baba9d9db47389c7f6604b2558df19 Mon Sep 17 00:00:00 2001 From: Victor Carreras <34163765+vicajilau@users.noreply.github.com> Date: Tue, 11 Feb 2025 13:25:44 +0100 Subject: [PATCH] throws exception when bytes are null --- lib/src/file_picker_io.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/file_picker_io.dart b/lib/src/file_picker_io.dart index 33e058b3..ff830897 100644 --- a/lib/src/file_picker_io.dart +++ b/lib/src/file_picker_io.dart @@ -146,12 +146,17 @@ class FilePickerIO extends FilePicker { Uint8List? bytes, bool lockParentWindow = false}) { if (Platform.isIOS || Platform.isAndroid) { + if (bytes == null) { + throw ArgumentError( + 'Bytes are required on Android & iOS when saving a file.'); + } + return _channel.invokeMethod("save", { "fileName": fileName, "fileType": type.name, "initialDirectory": initialDirectory, "allowedExtensions": allowedExtensions, - "bytes": bytes ?? Uint8List(0), + "bytes": bytes, }); } return super.saveFile(