我正在尝试使英雄动画从发布视图屏幕变为全屏发布视图。据我所知,这似乎很正常(我的代码),我真的不明白为什么会收到此错误...
我的代码中没有任何其他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,
),
),
),
),
);
}
}
非常感谢,非常感谢您的帮助!