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

[Web] Release picked file data for Web #1482

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 8.0.5
### Web
Release picked file data in memory to avoid memory leak

## 8.0.4
### Android
Removes references to Flutter v1 android embedding classes.
Expand Down
6 changes: 6 additions & 0 deletions lib/_internal/file_picker_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ class FilePickerWeb extends FilePicker {
_target.children.add(uploadInput);
uploadInput.click();

firstChild = _target.firstChild;
while (firstChild != null) {
_target.removeChild(firstChild);
firstChild = _target.firstChild;
}

final List<PlatformFile>? files = await filesCompleter.future;

return files == null ? null : FilePickerResult(files);
Expand Down
6 changes: 4 additions & 2 deletions lib/src/windows/file_picker_windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ class FilePickerWindows extends FilePicker {
String? initialDirectory,
}) {
int hr = CoInitializeEx(
nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
nullptr,
COINIT.COINIT_APARTMENTTHREADED | COINIT.COINIT_DISABLE_OLE1DDE,
);

if (!SUCCEEDED(hr)) throw WindowsException(hr);

Expand Down Expand Up @@ -134,7 +136,7 @@ class FilePickerWindows extends FilePicker {
if (!SUCCEEDED(hr)) {
CoUninitialize();

if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) {
if (hr == HRESULT_FROM_WIN32(WIN32_ERROR.ERROR_CANCELLED)) {
return Future.value(null);
}
throw WindowsException(hr);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A package that allows you to use a native file explorer to pick sin
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
repository: https://github.com/miguelpruivo/flutter_file_picker
issue_tracker: https://github.com/miguelpruivo/flutter_file_picker/issues
version: 8.0.4
version: 8.0.5

dependencies:
flutter:
Expand Down
Loading