Skip to content

Commit f77ed11

Browse files
CopilotAlexV525
andauthored
Fix crash on empty paths in onAssetsChanged (#737)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com>
1 parent 607e61d commit f77ed11

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ that can be found in the LICENSE file. -->
1212
**Fixes**
1313

1414
- Refactor drag selection to work across all pages globally.
15+
- Fix "Bad state: No element" crash in `onAssetsChanged` when paths list is empty.
1516

1617
## 10.0.0
1718

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,9 @@ class DefaultAssetPickerBuilderDelegate<T extends DefaultAssetPickerProvider>
10811081
}
10821082

10831083
await provider.getPaths(keepPreviousCount: true);
1084+
if (provider.paths.isEmpty) {
1085+
return;
1086+
}
10841087
provider.currentPath = provider.paths.first;
10851088
final currentWrapper = provider.currentPath;
10861089
if (currentWrapper != null) {

0 commit comments

Comments
 (0)