fix: no hero animation after tab change (#20285)

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2025-07-26 19:29:26 +05:30 committed by GitHub
parent d0576697c3
commit e85655d34c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 6 deletions

View file

@ -15,6 +15,7 @@ class ThumbnailTile extends ConsumerWidget {
this.fit = BoxFit.cover,
this.showStorageIndicator = true,
this.lockSelection = false,
this.heroOffset,
super.key,
});
@ -23,10 +24,11 @@ class ThumbnailTile extends ConsumerWidget {
final BoxFit fit;
final bool showStorageIndicator;
final bool lockSelection;
final int? heroOffset;
@override
Widget build(BuildContext context, WidgetRef ref) {
final heroOffset = TabsRouterScope.of(context)?.controller.activeIndex ?? 0;
final heroIndex = heroOffset ?? TabsRouterScope.of(context)?.controller.activeIndex ?? 0;
final assetContainerColor =
context.isDarkTheme ? context.primaryColor.darken(amount: 0.4) : context.primaryColor.lighten(amount: 0.75);
@ -67,7 +69,7 @@ class ThumbnailTile extends ConsumerWidget {
children: [
Positioned.fill(
child: Hero(
tag: '${asset.heroTag}_$heroOffset',
tag: '${asset.heroTag}_$heroIndex',
child: Thumbnail(
asset: asset,
fit: fit,