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

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

情况一:报错由于FloatingActionButton的heroTag引起的,看源码注释:

/// If this is not explicitly set, then there can only be one
/// [FloatingActionButton] per route (that is, per screen), since otherwise
/// there would be a tag conflict (multiple heroes on one route can't have the
/// same tag). The material design specification recommends only using one
/// floating action button per screen.
final Object heroTag;

大意是:如果没有显示设置FloatingActionButton 的heroTag 则一个页面只允许有一个FloatingActionButton,否则就会报上述错误.

解决办法:设置 FloatingActionButton的heroTag 为null;

情况二:报错是由于 CupertinoNavigationBar 的heroTag引起的,CupertinoNavigationBar使用在了tab页面,且页面实现了AutomaticKeepAliveClientMixin接口,但是不能设置heroTag为null,所有设置transitionBetweenRoutes:false即可。

/// Defaults to a common tag between all [CupertinoNavigationBar] and
  /// [CupertinoSliverNavigationBar] instances of the same [Navigator]. With the
  /// default tag, all navigation bars of the same navigator can transition
  /// between each other as long as there's only one navigation bar per route.
  ///
  /// This [heroTag] can be overridden to manually handle having multiple
  /// navigation bars per route or to transition between multiple
  /// [Navigator]s.
  ///
  /// Cannot be null. To disable Hero transitions for this navigation bar,
  /// set [transitionBetweenRoutes] to false.
  /// {@endtemplate} 

?mid=90f06&wid=51824&sid=&tid=7980&rid=MNTZ_LOADED&t=1578710503189

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值