diff --git a/CHANGELOG.md b/CHANGELOG.md index bccfaeea..fba10fe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/lib/_internal/file_picker_web.dart b/lib/_internal/file_picker_web.dart index f43f127a..0287f20d 100644 --- a/lib/_internal/file_picker_web.dart +++ b/lib/_internal/file_picker_web.dart @@ -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? files = await filesCompleter.future; return files == null ? null : FilePickerResult(files); diff --git a/lib/src/windows/file_picker_windows.dart b/lib/src/windows/file_picker_windows.dart index a5b92c94..ee5babe6 100644 --- a/lib/src/windows/file_picker_windows.dart +++ b/lib/src/windows/file_picker_windows.dart @@ -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); @@ -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); diff --git a/pubspec.yaml b/pubspec.yaml index 42771cb2..6147c99a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: