Skip to content

Commit

Permalink
Merge pull request #1482 from tddang-linagora/master
Browse files Browse the repository at this point in the history
[Web] Release picked file data for Web
  • Loading branch information
navaronbracke committed Jun 12, 2024
2 parents 4bef65a + 9c6cba9 commit 5e989e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
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

0 comments on commit 5e989e4

Please sign in to comment.