0

Tags only here, but gives the following error: "There are multiple heroes that share the same tag within a subtree."

bool isRightAligned = false;
bool t = false;
class ProfileBottom extends StatefulWidget {
  final Profile profile;
  final int photoIndex;
  final Function(bool) onIsRightAlignedChange;
  static void cancel() {

}

  const ProfileBottom({
    Key? key,
    required this.profile,
    required this.photoIndex,
    required this.onIsRightAlignedChange,
  }) : super(key: key);
  @override
  State<ProfileBottom> createState() => _ProfileBottomState();
}

class _ProfileBottomState extends State<ProfileBottom> {
  @override
  Widget build(BuildContext context) {
    final watchmodel = context.watch<ProfileModel>();
    return Hero(
      tag: 'tag3',
      child: Column(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          GestureDetector(
            onTap: () async {
              isRightAligned = !isRightAligned;
              setState(() {});
              widget.onIsRightAlignedChange(isRightAligned); // Добавить
              Future.delayed(Duration(milliseconds: 100), () {
                Navigator.push(context, MaterialPageRoute(builder: (context) => UserProfile(profile: widget.profile, scrollController: ScrollController())));
              //  onDetailsTap(context);
              });
            },
            child: AnimatedContainer(
              duration: Duration(milliseconds: 230),
              curve: Curves.easeInOut,
              transform: Matrix4.translationValues(
                isRightAligned
                    ? MediaQuery.of(context).size.width
                    : 0,
                0,
                0,
              ),
              child: Column(
                children: [
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Row(
                            mainAxisSize: MainAxisSize.min,
                            children: [
                              Text(
                                widget.profile.username,
                                style: AppTextStyle.headline,
                              ).paddingOnly(right: 12.w),
                              Text(
                                '21',
                                style: AppTextStyle.headlineLight,
                              ),
                            ],
                          ),
                          16.h.heightBox,
                          InterestsWrap(interests: widget.profile.preferences),
                          16.h.heightBox,
                          SizedBox(
                            height: 60.h,
                            width: 267.w,
                            child: Text(
                              widget.profile.bio,
                              style: AppTextStyle.textReg15White,
                              overflow: TextOverflow.ellipsis,
                            ),
                          ),
                          20.h.heightBox,
                        ],
                      ),
                      Align(
                        child: const ReactionsPanel()
                            .paddingOnly(bottom: 18.h, right: 24.w),
                        alignment: Alignment(3, 0),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),
          CarouselImageIndicatorWidget(
            photoLength: widget.profile.avatars.length,
            photoIndex: watchmodel.ind,
          ),
          14.h.heightBox,
        ],
      ),
    );
  }
}

this is the first screen

class UserProfile extends StatefulWidget {
  final Profile profile;
  final ScrollController scrollController;

  const UserProfile({
    Key? key,
    required this.profile,
    required this.scrollController,
  }) : super(key: key);

  @override
  State<UserProfile> createState() => _UserProfileState();
}

class _UserProfileState extends State<UserProfile> {
  int _current = 0;

  @override
  Widget build(BuildContext context) {
    return Hero(
      tag: 'tag3',
      child: Material(
        borderOnForeground: false,
        color: Color(0xffffffff).withOpacity(0),
        child: Stack(
          children: [
            ListView(
              padding: EdgeInsets.zero,
              controller: widget.scrollController,
              physics: const BouncingScrollPhysics(),
              children: [
                SizedBox(
                  height: 666.h,
                  child: Stack(
                    children: [
                      CarouselPhotos(
                        profile: widget.profile,
                        darkened: true,

                      ),
                      Column(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              Text(
                                widget.profile.username,
                                style: AppTextStyle.headline,
                              ).paddingOnly(right: 12.w),
                              Text(
                                '24', //возраст подопытного (резко постарел на 3 года)
                                style: AppTextStyle.headlineLight,
                              ),
                            ],
                          ),
                          12.h.heightBox,
                          const Text(
                            '4 км от вас', //знакомо
                            style: AppTextStyle.textReg15Grey,
                          ),
                          32.h.heightBox,
                          CarouselImageIndicatorWidget(
                            photoLength: widget.profile.avatars.length,
                            photoIndex: _current,
                          ),
                        ],
                      ).paddingOnly(bottom: 10.h),
                    ],
                  ),
                ),
                24.h.heightBox,
                Text(
                  widget.profile.bio,
                  style: AppTextStyle.textReg17w400White,
                ).paddingSymmetric(horizontal: 20.w),
                28.h.heightBox,
                if (widget.profile.passions.isNotEmpty) ...[
                  const Text(
                    'Интересы', // видимо их нет по этому не показывается надпись
                    style: AppTextStyle.textReg17w400White,
                  ).paddingSymmetric(horizontal: 20.w),
                  12.h.heightBox,
                  InterestsWrap(
                    interests: widget.profile.passions,
                    isLight: true,
                  ).paddingSymmetric(horizontal: 20.w),
                ],
                24.h.heightBox,
                if (widget.profile.preferences.isNotEmpty) ...[
                  const Text(
                    'Предпочтения', // тут всё ясно
                    style: AppTextStyle.textReg17w400White,
                  ).paddingSymmetric(horizontal: 20.w),
                  12.h.heightBox,
                  InterestsWrap(
                    interests: widget.profile.preferences,
                    isLight: true,
                  ).paddingSymmetric(horizontal: 20.w),
                ],
                70.h.heightBox,
              ],
            ),
            Align(
              alignment: Alignment.topRight,
              child: ZoomTapAnimation(
                onTap: () {
                  isRightAligned = !isRightAligned;
                  Navigator.of(context).pop({
                    Future.delayed(Duration(milliseconds: 150), () {
                      setState(() {});
                    })
                  });
                  ProfileBottom.cancel();
                },
                child: SizedBox(
                  height: 44.w,
                  width: 42.w,
                  child: SvgPicture.asset(
                    'assets/icons/close.svg',
                    width: 22.w,
                  ).paddingSymmetric(horizontal: 10.w, vertical: 5.w),
                ),
              ),
            ).paddingOnly(right: 8.w, top: 40.w),
          ],
        ),
      ),
    );
  }
}
}

this is the second screen

tags only here, but gives the following error: "There are multiple heroes that share the same tag within a subtree."

I read a lot of information, but did not find a solution. This is the first time I'm facing this kind of problem.

0 Answers0