Skip to content

Commit ff6cf10

Browse files
committed
🚑️ Fix value key issue between paths
1 parent f455c24 commit ff6cf10

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ abstract class AssetPickerBuilderDelegate<A, P> {
252252
/// The main grid view builder for assets.
253253
/// 主要的资源查看网格部件
254254
Widget assetsGridBuilder(BuildContext context) {
255+
final int hashCode = provider.currentPathEntity?.hashCode ?? 0;
255256
return ColoredBox(
256257
color: theme.canvasColor,
257258
child: Selector<AssetPickerProvider<A, P>, List<A>>(
@@ -269,16 +270,16 @@ abstract class AssetPickerBuilderDelegate<A, P> {
269270
SliverGrid(
270271
delegate: SliverChildBuilderDelegate(
271272
(_, int index) => Builder(
272-
key: ValueKey<int>(index),
273+
key: ValueKey<int>(index + hashCode),
273274
builder: (BuildContext c) => assetGridItemBuilder(
274275
c,
275276
index,
276277
currentAssets,
277278
),
278279
),
279280
childCount: assetsGridItemCount(_, currentAssets),
280-
findChildIndexCallback: (Key? key) =>
281-
(key as ValueKey<int>?)?.value,
281+
findChildIndexCallback: (Key key) =>
282+
(key as ValueKey<int>).value - hashCode,
282283
),
283284
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
284285
crossAxisCount: gridCount,

0 commit comments

Comments
 (0)