该问题原因多个widget重复使用同一GlobalKey导致的,
我的代码如下:
// 初始化一个 GlobalKey 传递 key 从SliverCollapsingWidget 到 NftBlurImageWidget 传递过程中两个weidget同时使用了videoKey
final GlobalKey<VideoWidgetState> videoKey = GlobalKey();
SliverCollapsingWidget(
key: videoKey,
tag: tag,
heroTag: widget.heroTag,
)),
),
class SliverCollapsingWidget extends StatelessWidget {
final String tag;
final String heroTag;
final GlobalKey<VideoWidgetState> videoKey;
const SliverCollapsingWidget({
Key key,
this.tag,
@required this.videoKey,
@required this.heroTag,
}) : super(key: key);
....
child: NftBlurImageWidget(
key: videoKey,
heroTag: heroTag ?? "",
avatarUrl: controller.model?.avatarUrl ?? "",
)
class NftBlurImageWidget extends StatelessWidget {
const NftBlurImageWidget({
Key key,
@required this.avatarUrl,
@required this.backgroundUrl,
@required this.heroTag,
@required this.videoKey,
}) : super(key: key);
修改方法 不要使用自带key ,要使用重命名参数key传递
|