switchPath method

  1. @override
Future<void> switchPath([
  1. AssetPathEntity? path
])
override

Switch between paths. 切换路径

Implementation

@override
Future<void> switchPath([AssetPathEntity? path]) async {
  assert(
    () {
      if (_currentPath == null && path == null) {
        throw FlutterError.fromParts(<DiagnosticsNode>[
          ErrorSummary('Empty $AssetPathEntity was switched.'),
          ErrorDescription(
            'Neither currentPathEntity nor pathEntity is non-null, '
            'which makes this method useless.',
          ),
          ErrorHint(
            'You need to pass a non-null $AssetPathEntity '
            'or call this method when currentPathEntity is not null.',
          ),
        ]);
      }
      return true;
    }(),
  );
  if (_currentPath == null && path == null) {
    return;
  }
  path ??= _currentPath!;
  _currentPath = path;
  _totalAssetsCount = path.assetCount;
  notifyListeners();
  await getAssetsFromPath(0, currentPath!);
}