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

Fix: Handle Null Byte Array in saveFile Method #1662

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vicajilau
Copy link

Context

This PR addresses an issue in the FilePicker.platform.saveFile method where passing a null Uint8List causes failures. This issue is primarily observed on Android (API 35), but the solution is implemented for both Android and iOS to ensure consistency.

Root Cause

The null value for Uint8List was not handled correctly, leading to exceptions during file operations. Specifically:

  • On Android, null values caused crashes when attempting to write to the file system.

Solution

The fix ensures that:

  1. If a Uint8List is null, it is replaced with an empty Uint8List(0) before being processed.
  2. The change has been tested on both Android and iOS platforms and confirmed to function without issues.

Changes

  • Updated the saveFile method to replace null Uint8List with Uint8List(0).
  • Ensured platform-specific implementations in both Android and iOS handle this case consistently.

Testing

  • Verified on Android API 35 to resolve the crash.
  • Tested on iOS to confirm that the change does not introduce new issues.

References

Notes

This fix aligns with the goal of ensuring robustness in file operations across platforms, avoiding unexpected crashes due to null parameter values.

Checklist

  • Code changes reviewed.
  • Tested on Android API 35.
  • Tested on iOS for compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant