颤抖的多个英雄在一个子树中共享相同的标签

时间:2020-07-25 15:00:01

标签: android ios flutter animation dart

我正在尝试使英雄动画从发布视图屏幕变为全屏发布视图。据我所知,这似乎很正常(我的代码),我真的不明白为什么会收到此错误...

我的代码中没有任何其他Hero小部件,所以我看不到为什么会出现此错误...

这是我遇到的错误:

There are multiple heroes that share the same tag within a subtree.

这是我的代码:

Stack(
            alignment: Alignment.center,
            children: <Widget>[
              Hero(
                tag: 'test',
                child: Container(
                  height: MediaQuery.of(context).size.width,
                  child: Padding(
                    padding: const EdgeInsets.all(6.0),
                    child: Align(
                      alignment: Alignment.topRight,
                      child: Container(
                        decoration: BoxDecoration(
                          color: Colors.grey.shade400.withOpacity(0.5),
                          borderRadius: BorderRadius.circular(12.0),
                        ),
                        width: 120,
                        height: 40,
                        child: ListView.builder(
                          scrollDirection: Axis.horizontal,
                          itemCount: 3,
                          itemBuilder: (BuildContext context, int index) {
                            return _configureEmoji(index);
                          },
                        ),
                      ),
                    ),
                  ),
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      image: CachedNetworkImageProvider(widget.post.imageURL),
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
              ),
            ],
          ),

在这里我要英雄动画去:

class FullScreenView extends StatelessWidget {
  final String imageURL;
  FullScreenView({this.imageURL});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Hero(
        tag: 'test',
        child: Container(
          width: MediaQuery.of(context).size.width,
          height: MediaQuery.of(context).size.height,
          decoration: BoxDecoration(
            image: DecorationImage(
              image: CachedNetworkImageProvider(imageURL),
              fit: BoxFit.cover,
            ),
          ),
        ),
      ),
    );
  }
}

非常感谢,非常感谢您的帮助!

0 个答案:

没有答案