unique image tag

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-03-16 15:19:30 +08:00
parent ed66a4655b
commit 8a8aa6c1e0
5 changed files with 10 additions and 4 deletions

View File

@@ -108,6 +108,7 @@ class ImageGridView extends StatelessWidget {
PageUtils.imageView( PageUtils.imageView(
initialPage: index, initialPage: index,
imgList: imgList, imgList: imgList,
tag: hashCode.toString(),
); );
} }
@@ -255,7 +256,7 @@ class ImageGridView extends StatelessWidget {
); );
if (!item.isLongPic) { if (!item.isLongPic) {
child = Hero( child = Hero(
tag: item.url, tag: '${item.url}$hashCode',
child: child, child: child,
); );
} }

View File

@@ -55,6 +55,7 @@ class GalleryViewer extends StatefulWidget {
required this.sources, required this.sources,
this.initIndex = 0, this.initIndex = 0,
this.onPageChanged, this.onPageChanged,
this.tag = '',
}); });
final double minScale; final double minScale;
@@ -63,6 +64,7 @@ class GalleryViewer extends StatefulWidget {
final List<SourceModel> sources; final List<SourceModel> sources;
final int initIndex; final int initIndex;
final ValueChanged<int>? onPageChanged; final ValueChanged<int>? onPageChanged;
final String tag;
@override @override
State<GalleryViewer> createState() => _GalleryViewerState(); State<GalleryViewer> createState() => _GalleryViewerState();
@@ -472,7 +474,7 @@ class _GalleryViewerState extends State<GalleryViewer>
: const SizedBox.shrink(), : const SizedBox.shrink(),
); );
} }
return Hero(tag: item.url, child: child); return Hero(tag: '${item.url}${widget.tag}', child: child);
} }
void _onTap() { void _onTap() {

View File

@@ -90,6 +90,7 @@ Widget content(
), ),
if (pics != null && pics.isNotEmpty) if (pics != null && pics.isNotEmpty)
ImageGridView( ImageGridView(
fullScreen: true,
picArr: pics picArr: pics
.map( .map(
(item) => ImageModel( (item) => ImageModel(
@@ -100,7 +101,6 @@ Widget content(
), ),
) )
.toList(), .toList(),
fullScreen: true,
), ),
], ],
), ),

View File

@@ -429,7 +429,7 @@ class UserInfoCard extends StatelessWidget {
); );
Widget _buildAvatar(bool hasPendant) => fromHero( Widget _buildAvatar(bool hasPendant) => fromHero(
tag: card.face ?? '', tag: '${card.face}$hashCode',
child: PendantAvatar( child: PendantAvatar(
avatar: card.face, avatar: card.face,
size: hasPendant ? kPendantAvatarSize : kAvatarSize, size: hasPendant ? kPendantAvatarSize : kAvatarSize,
@@ -440,6 +440,7 @@ class UserInfoCard extends StatelessWidget {
garbPendantImage: card.pendant?.image, garbPendantImage: card.pendant?.image,
roomId: live?.liveStatus == 1 ? live!.roomid : null, roomId: live?.liveStatus == 1 ? live!.roomid : null,
onTap: () => PageUtils.imageView( onTap: () => PageUtils.imageView(
tag: hashCode.toString(),
imgList: [SourceModel(url: card.face.http2https)], imgList: [SourceModel(url: card.face.http2https)],
), ),
), ),

View File

@@ -49,6 +49,7 @@ abstract final class PageUtils {
required List<SourceModel> imgList, required List<SourceModel> imgList,
int? quality, int? quality,
ValueChanged<int>? onPageChanged, ValueChanged<int>? onPageChanged,
String tag = '',
}) { }) {
return Get.key.currentState!.push<void>( return Get.key.currentState!.push<void>(
HeroDialogRoute( HeroDialogRoute(
@@ -57,6 +58,7 @@ abstract final class PageUtils {
initIndex: initialPage, initIndex: initialPage,
quality: quality ?? GlobalData().imgQuality, quality: quality ?? GlobalData().imgQuality,
onPageChanged: onPageChanged, onPageChanged: onPageChanged,
tag: tag,
), ),
), ),
); );