Skip to content

Commit 8a6f6b3

Browse files
committed
⚡️ Reset to the top after switching path
1 parent 5468f84 commit 8a6f6b3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ abstract class AssetPickerBuilderDelegate<A, P> {
8282
/// 当没有资源时是否显示自定义item
8383
final bool allowSpecialItemWhenEmpty;
8484

85+
/// The [ScrollController] for the preview grid.
86+
final ScrollController gridScrollController = ScrollController();
87+
8588
/// [ThemeData] for the picker.
8689
/// 选择器使用的主题
8790
ThemeData get theme => pickerTheme ?? AssetPicker.themeData(themeColor);
@@ -261,6 +264,7 @@ abstract class AssetPickerBuilderDelegate<A, P> {
261264
selector: (_, AssetPickerProvider<A, P> provider) =>
262265
provider.currentAssets,
263266
builder: (_, List<A> currentAssets, __) => GridView.builder(
267+
controller: gridScrollController,
264268
padding: isAppleOS
265269
? EdgeInsets.only(
266270
top: Screens.topSafeHeight + kToolbarHeight,
@@ -1031,7 +1035,10 @@ class DefaultAssetPickerBuilderDelegate
10311035
type: MaterialType.transparency,
10321036
child: InkWell(
10331037
splashFactory: InkSplash.splashFactory,
1034-
onTap: () => provider.switchPath(pathEntity),
1038+
onTap: () {
1039+
provider.switchPath(pathEntity);
1040+
gridScrollController.jumpTo(0);
1041+
},
10351042
child: SizedBox(
10361043
height: isAppleOS ? 64.0 : 52.0,
10371044
child: Row(

0 commit comments

Comments
 (0)