今天写Demo的时候遇到了下面的错误:

I/flutter: ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter: The following assertion was thrown during a scheduler callback:
I/flutter: There are multiple heroes that share the same tag within a subtree.
I/flutter: Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), each Hero must
I/flutter: have a unique non-null tag.
I/flutter: In this case, multiple heroes had the following tag: <default FloatingActionButton tag>
I/flutter: Here is the subtree for one of the offending heroes:
I/flutter: # Hero(tag: <default FloatingActionButton tag>, state: _HeroState#c0b28)
...

大致意思是说:
在程序回调的的时候发生了以下断言:
在子树中有多个Hero 对象共用了一个tag,每个Hero对象的tag必须是惟一的。

并且指出了是FloatingActionButton中的tag 有冲突。

以前都没注意到这个东西,来看一下FloatingActionButton 中的 tag吧。


可以看到 heroTag 有个默认值:<default FloatingActionButton tag>

而刚好我的页面中有两个 FloatingActionButton,所以就导致heroTag 冲突了。

解决办法很简单,给FloatingActionButton 的heroTag 赋一个新的值。


这样就可以正常使用了。

归根到底还是 Hero对象中的tag必须唯一,从下面报错的地方就可以看到了:

所以类似报错都可以直接找到有使用Hero对象的地方就行了。

Flutter: There are multiple heroes that share the same tag within a subtree异常相关推荐

  1. Flutter典型错误:There are multiple heroes that share the same tag within a subtree.

    这段错误信息描述通常如下:'Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), ea ...

  2. Flutter笔记-There are multiple heroes that share the same tag within a subtree

    在使用FloatingActionButton时报错了 floatingActionButton: Row(mainAxisAlignment: MainAxisAlignment.center,cr ...

  3. Flutter报错总结:There are multiple heroes that share the same tag within a subtree.

    最近在项目中遇到了问题:点击每个页面都显示黑屏,并且控制台报错:There are multiple heroes that share the same tag within a subtree. ...

  4. 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的her ...

  5. Another exception was thrown: There are multiple heroes that share the same tag w

    报错: I/flutter (18994): Another exception was thrown: There are multiple heroes that share the same t ...

  6. [译] Flutter 的 Heroes 和 Villains —— 为 Flutterverse 带来平衡

    原文地址:Flutter Heroes and Villains - bringing balance to the Flutterverse. 原文作者:Norbert 译文出自:掘金翻译计划 本文 ...

  7. 给 iOS 开发者的 Flutter 指南

    目录 Views 视图 What is the equivalent of a UIView in Flutter? UIView 相当于 Flutter 中的什么? How do I update ...

  8. 富文本中添加字体选项功能_扑中的字体功能

    富文本中添加字体选项功能 A little extra help for styling your text 样式设置方面的一些额外帮助 I recently learned about a litt ...

  9. android hero动画,主动画 (Hero animations)

    主动画 (Hero animations) 你将会在这里学到: What you'll learn Hero 指的是在屏幕间飞跃的 widget. The hero refers to the wid ...

最新文章

  1. RDB 和 AOF 持久化的原理是什么?我应该用哪一个?它们的优缺点?
  2. DataTables 表格固定栏使用方法
  3. Geospark-SQL加载SHP数据
  4. 正确使用cookie中的domain
  5. 区块链和java哪个更难_java 区块链中设计合理的难度系数
  6. Xilinx Vivado的使用详细介绍(1):创建工程、编写代码、行为仿真、Testbench
  7. 从机器学习到深度学习
  8. ERP系统各子系统功能模块页面
  9. 苹果手机数据线充不了电_自动洗地机充不了电,洗地机厂家
  10. mac foxmail html签名,Foxmail for mac邮箱账号添加设置图文教程
  11. 彻底关闭Adobe Flash Player的弹窗广告(不影响Flash正常使用)
  12. 利用callgrind+gprof2dot+dot进行性能分析
  13. 单片机C语言-include、sfr和sbit 的讲解
  14. latex 单元格 斜杠_如何在Excel中的单元格中启用键入斜杠
  15. class.forName
  16. seaborn seaborn色板的使用设置(二)
  17. 织梦模板下载:环保设计公司织梦模板
  18. 菲涅耳衍射,夫琅禾费衍射
  19. 美团点评java开发面试问题
  20. java properties 遍历_如何遍历properties文件的键值对并放置到application作用域里

热门文章

  1. Linux 没声音问题解决方案之一——设置正确的模组
  2. 毕业一年,我是如何成为Apache项目的Committer
  3. 开心网,很开心!!!
  4. FCKeditor学习笔记
  5. c语言应用论文英文,c语言中英文翻译资料 本科毕业论文(设计).doc
  6. AD20铺铜显示和隐藏的设置
  7. RGBYUV图像视频格式
  8. 一文掌握 YUV 图像的基本处理
  9. Nvidia GTC China 19 keynote
  10. 北大青鸟ACCP5.0课程体系介绍