in my app I've got this small sub-widget in a list that redirects me to the profile page of the author of the ad with a Hero animation. The problem that I'm facing right now, is that if there's two ads with the same author, there will be two hero tags which are the same (which is normal 'cause they redirect to the same page). But flutter doesn't allow to have multiple Hero widgets with the same hero tag.

enter image description here

A solution would be to get a value that is proper to the object and that would be different even if the objects have the same properties. A kind of equivalent to the reference, or the memory location in java. But I haven't found such a thing for dart on the internet :/


Solution 1: Islomkhuja Akhrarov

You cannot see directly of adress of your instance in dart, but You can use id in model if you have for tag or Instance of Class f.e Entity().


Solution 2: user54517

Ok, I think the best way is just to generate a random tag, and pass it to the destiantion page :

  @override
  Widget build(BuildContext context) {
    final String randomTag = Uuid().v4();
    return GestureDetector(
      onTap: () {
        context.read<NavigatorBloc>().add(GoToProfileDetailScreen(author: author, tag : randomTag));
      },
      child: Row(
        children: <Widget>[
          SizedBox(
            width: isDetail ? 30.0 : 20.0,
            height: isDetail ? 30.0 : 20.0,
            child: Hero(
              tag: randomTag,