getAssetsFromPath method

  1. @override
Future<void> getAssetsFromPath([
  1. int? page,
  2. AssetPathEntity? path
])
override

Get assets under the specific path entity. 获取指定路径下的资源

Implementation

@override
Future<void> getAssetsFromPath([int? page, AssetPathEntity? path]) {
  Future<void> run() async {
    final int currentPage = page ?? currentAssetsListPage;
    final AssetPathEntity currentPath = path ?? this.currentPath!.path;
    final List<AssetEntity> list = await currentPath.getAssetListPaged(
      page: currentPage,
      size: pageSize,
    );
    if (currentPage == 0) {
      _currentAssets.clear();
    }
    _currentAssets.addAll(list);
    _hasAssetsToDisplay = _currentAssets.isNotEmpty;
    notifyListeners();
  }

  if (_getAssetsFromPathCompleter == null) {
    _getAssetsFromPathCompleter = Completer<void>();
    run().then((_) {
      _getAssetsFromPathCompleter!.complete();
    }).catchError((Object e, StackTrace s) {
      _getAssetsFromPathCompleter!.completeError(e, s);
    }).whenComplete(() {
      _getAssetsFromPathCompleter = null;
    });
  }
  return _getAssetsFromPathCompleter!.future;
}