扑多个英雄共享同一标签带按钮的ListView

问题描述

无法弄清楚如何解决此问题。因此,这是代表我的问题的最简单的代码

   Scaffold(
      body: Stack(
        children: <Widget>[
          ...
          Scrollbar(
            child: ListView.builder(
              primary: false,shrinkWrap: true,itemCount: _mapBloc?.mapData?.companies?.count ?? 0,itemBuilder: (context,index) {
                final company = _mapBloc?.mapData?.companies?.data[index];
                return InkWell(
                  child: Hero(
                    tag: company.id,child: Card(
                      child: Container(
                        height: 50,width: double.infinity,),onTap: () {
                    Navigator.of(context)
                        .pushNamed('/company',arguments: company)
                        .then(
                      (results) {
                        if (results is PopWithResults) {
                          PopWithResults popResult = results;
                        }
                      },);
                  },);
              },)
        ],);

堆栈跟踪:

The following assertion was thrown during a scheduler callback:
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),each Hero must
have a unique non-null tag.
...

ListView中的项目计数随每个数据库请求而变化。如果在ListView中,小部件的大小最多为5个,则在列表扩展到例如8个元素后,单击即可正常工作,我得到上面写的错误。用什么可以连接?我尝试使用唯一的Hero标签,但这不能解决问题。

我需要一些建议,希望您能帮助我。如果您需要更多信息,请写评论

感谢您的关注!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)