Skip to content

Scope 13.0.0: nullable PlatformFile.length() and removal of parameters deprecated since 12.0.0 - #2203

Merged
vicajilau merged 3 commits into
mainfrom
feat/scope-v13-length-nullable-and-deprecated-cleanup
Sep 11, 2026
Merged

vicajilau merged 3 commits into
mainfrom
feat/scope-v13-length-nullable-and-deprecated-cleanup

Conversation

@vicajilau

Copy link
Copy Markdown
Owner

Implements the scope agreed in #2202.

PlatformFile.length() becomes Future<int?>

Fixes #2197.

length() returned 0 both for a genuinely empty file and for a failed lookup, with no way to tell them apart. It now returns null in the failure case, matching lengthSync(), across the platform interface and all five platform implementations (Android, Darwin, Linux, Web, Windows).

Removal of parameters deprecated since 12.0.0

Removed from FilePicker.pickFiles()/pickFile()/getDirectoryPath()/saveFile():

  • allowMultiple, withData, withReadStream, readSequential
  • lockParentWindow (the top level one, not WindowsOptions.lockParentWindow/LinuxOptions.lockParentWindow)
  • cancelUploadOnWindowBlur
  • androidSafOptions

None of these were ever forwarded to the platform implementations except androidSafOptions, which is now folded into androidOptions directly (matching what the deprecation message already pointed callers to).

Versioning

  • file_picker_platform_interface: 3.3.0 to 4.0.0
  • android_file_picker, file_picker_darwin, file_picker_linux, windows_file_picker: to 2.0.0
  • file_picker_web: 3.1.0 to 4.0.0
  • file_picker: 12.2.0 to 13.0.0

Also updated the example app and its tests, and added a "Migrating to v13" section to the README.

Test plan

  • melos exec -- flutter analyze . clean across all 8 packages
  • melos exec -- flutter test all green across all 8 packages
  • dart format --output=none --set-exit-if-changed . clean

…eprecated since 12.0.0

Implements the plan agreed in #2202.

PlatformFile.length() now returns Future<int?> across the interface and all
five platform implementations, using null to mean the length could not be
determined, distinct from a genuinely empty file which still returns 0.
Fixes #2197.

Removed the parameters deprecated since the 12.0.0 federated rewrite:
allowMultiple, withData, withReadStream, readSequential, lockParentWindow,
cancelUploadOnWindowBlur, and androidSafOptions on FilePicker's pickFiles(),
pickFile(), getDirectoryPath(), and saveFile().

Bumped file_picker to 13.0.0, file_picker_platform_interface to 4.0.0, and
android_file_picker, file_picker_darwin, file_picker_linux, windows_file_picker
to 2.0.0 and file_picker_web to 4.0.0, updated the example app and tests, and
added a Migrating to v13 section to the README.
…-nullable-and-deprecated-cleanup

# Conflicts:
#	example/lib/src/file_picker_demo.dart
#	packages/file_picker/CHANGELOG.md
#	packages/file_picker/pubspec.yaml
#	packages/file_picker_darwin/CHANGELOG.md
#	packages/file_picker_darwin/pubspec.yaml
#	packages/file_picker_platform_interface/CHANGELOG.md
#	packages/file_picker_platform_interface/pubspec.yaml
#	packages/file_picker_windows/CHANGELOG.md
#	packages/file_picker_windows/pubspec.yaml
@vicajilau

Copy link
Copy Markdown
Owner Author

Everyting ready for your review @navaronbracke 🚀

withData: _withData,
androidSafOptions: _androidSafOptionsFromFlags(),
androidOptions:
_androidSafOptionsFromFlags() ?? const AndroidOptions(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could _androidSafOptionsFromFlags() default to returning const AndroidOptions() as fallback, so it is a non null result? That would avoid some repetition

@navaronbracke

Copy link
Copy Markdown
Collaborator

@vicajilau Once this is merged, we can start removing the deprecated options in native code in cleanup pull requests 🚀

@vicajilau
vicajilau merged commit 095b7ac into main Sep 11, 2026
17 of 18 checks passed
@vicajilau
vicajilau deleted the feat/scope-v13-length-nullable-and-deprecated-cleanup branch September 11, 2026 07:35
vicajilau added a commit that referenced this pull request Sep 11, 2026
Follow-up cleanup suggested in #2203, after that PR removed the deprecated
withData facade parameter that used to control this.

The Dart plugin for Android and iOS has not sent a withData argument over
the method channel since the 12.0.0 federated rewrite, so loadDataToMemory
was permanently pinned to false on both platforms already, no picked file
was ever eagerly read into memory. Removed the parameter threading through
FilePickerPlugin.kt, FilePickerDelegate.kt, FileUtils.kt on Android and
IOSFilePickerHandler.swift on iOS, along with the now unreachable eager
read branches, the loadData() helper, and the bytes wire key it populated
(also dropped from FileInfo.toMap() and the corresponding Dart fromMap()
parsing). PlatformFile.readAsBytes() already reads lazily on demand and is
unaffected.

Verified with flutter build apk, flutter build macos, and flutter build
ios --simulator, plus analyze/test/format across the workspace.
vicajilau added a commit that referenced this pull request Sep 11, 2026
Follow-up cleanup suggested in #2203, after that PR removed the deprecated
withData facade parameter that used to control this.

The Dart plugin for Android and iOS has not sent a withData argument over
the method channel since the 12.0.0 federated rewrite, so loadDataToMemory
was permanently pinned to false on both platforms already, no picked file
was ever eagerly read into memory. Removed the parameter threading through
FilePickerPlugin.kt, FilePickerDelegate.kt, FileUtils.kt on Android and
IOSFilePickerHandler.swift on iOS, along with the now unreachable eager
read branches, the loadData() helper, and the bytes wire key it populated
(also dropped from FileInfo.toMap() and the corresponding Dart fromMap()
parsing). PlatformFile.readAsBytes() already reads lazily on demand and is
unaffected.

Verified with flutter build apk, flutter build macos, and flutter build
ios --simulator, plus analyze/test/format across the workspace.
@vicajilau

Copy link
Copy Markdown
Owner Author

@vicajilau Once this is merged, we can start removing the deprecated options in native code in cleanup pull requests 🚀

Yes!! #2205 is ready

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.

PlatformFile.length() returns 0 when it fails, which is also a valid length

2 participants