Skip to content

Commit 39475e0

Browse files
committed
♻️ Extract DefaultAssetPickerProvider.init
1 parent e1a966b commit 39475e0

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

CHANGELOG.md

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

1818
- Improve how `MediaQuery` is being listened.
1919
- Stop enabling drag to select when `maxAssets == 1`.
20+
- Extract `DefaultAssetPickerProvider.init`.
2021

2122
**Fixes**
2223

lib/src/provider/asset_picker_provider.dart

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,7 @@ class DefaultAssetPickerProvider
272272
this.filterOptions,
273273
Duration initializeDelayDuration = const Duration(milliseconds: 250),
274274
}) {
275-
Singleton.sortPathDelegate = sortPathDelegate ?? SortPathDelegate.common;
276-
// Call [getAssetList] with route duration when constructing.
277-
Future<void>.delayed(initializeDelayDuration, () async {
278-
await getPaths(onlyAll: true);
279-
await getPaths(onlyAll: false);
280-
});
275+
init(initializeDelayDuration);
281276
}
282277

283278
@visibleForTesting
@@ -311,6 +306,25 @@ class DefaultAssetPickerProvider
311306
/// 将会与基础条件进行合并。
312307
final PMFilter? filterOptions;
313308

309+
/// Initialize the provider.
310+
void init(Duration initializeDelayDuration) {
311+
Singleton.sortPathDelegate = sortPathDelegate ?? SortPathDelegate.common;
312+
// Call [getAssetList] with route duration when constructing.
313+
Future<void>.delayed(initializeDelayDuration, () async {
314+
if (_mounted) {
315+
return;
316+
}
317+
318+
await getPaths(onlyAll: true);
319+
320+
if (_mounted) {
321+
return;
322+
}
323+
324+
await getPaths(onlyAll: false);
325+
});
326+
}
327+
314328
@override
315329
set currentPath(PathWrapper<AssetPathEntity>? value) {
316330
if (value == _currentPath) {

0 commit comments

Comments
 (0)