flutter GridView causes Navigator.push error










0














My flutter app has a button to go to a contact page. It is working well when the GridView has only one floatingButton. But it will have error when the GridView has more than one floatingButton. Please help to solve this issue.



Error:



  • flutter: The following assertion was thrown during a scheduler callback:

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

  • flutter: Within each subtree for which heroes are to be animated (typically a PageRoute subtree), each Hero

  • flutter: must have a unique non-null tag.

  • flutter: In this case, multiple heroes had the following tag:

  • flutter: Here is the subtree for one of the offending heroes:

  • flutter: # Hero(tag: , state: _HeroState#232b6)

enter image description here



class _DatabasePageState extends State<DatabasePage> 
@override
Widget build(BuildContext context)
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: Text('DB'),
centerTitle: true,
backgroundColor: Colors.black,
),
body: _showOrderdatabase(),

);


Widget _showOrderdatabase()

return Column(
children: <Widget>[
Container(
height: 220.0,
color: Colors.transparent,
child: new Container(
padding: EdgeInsets.all(40.0),
decoration: new BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.all(const Radius.circular(40.0)),
),
child: new Column(
children: <Widget>[
Text(
"vds",
style: TextStyle(fontSize: 16.0),
),
IconButton(
icon: Icon(
Icons.email,
color: Colors.blueAccent,
),
iconSize: 50.0,
onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (c) => new ContactUs())),
),
],
)),
),
Expanded(
child: GridView.count(
primary: false,
padding: const EdgeInsets.all(20.0),
crossAxisSpacing: 30.0,
mainAxisSpacing: 30.0,
crossAxisCount: 4,
children: <Widget>[
FloatingActionButton(
onPressed: null,
backgroundColor: Colors.orange,
child: Text('今天'),
foregroundColor: Colors.black,
),
FloatingActionButton(
onPressed: null,
backgroundColor: Colors.yellow,
child: Text('年'),
foregroundColor: Colors.black,
),

],
),
)
],
);











share|improve this question


























    0














    My flutter app has a button to go to a contact page. It is working well when the GridView has only one floatingButton. But it will have error when the GridView has more than one floatingButton. Please help to solve this issue.



    Error:



    • flutter: The following assertion was thrown during a scheduler callback:

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

    • flutter: Within each subtree for which heroes are to be animated (typically a PageRoute subtree), each Hero

    • flutter: must have a unique non-null tag.

    • flutter: In this case, multiple heroes had the following tag:

    • flutter: Here is the subtree for one of the offending heroes:

    • flutter: # Hero(tag: , state: _HeroState#232b6)

    enter image description here



    class _DatabasePageState extends State<DatabasePage> 
    @override
    Widget build(BuildContext context)
    return Scaffold(
    backgroundColor: Colors.black,
    appBar: AppBar(
    title: Text('DB'),
    centerTitle: true,
    backgroundColor: Colors.black,
    ),
    body: _showOrderdatabase(),

    );


    Widget _showOrderdatabase()

    return Column(
    children: <Widget>[
    Container(
    height: 220.0,
    color: Colors.transparent,
    child: new Container(
    padding: EdgeInsets.all(40.0),
    decoration: new BoxDecoration(
    color: Colors.green,
    borderRadius: BorderRadius.all(const Radius.circular(40.0)),
    ),
    child: new Column(
    children: <Widget>[
    Text(
    "vds",
    style: TextStyle(fontSize: 16.0),
    ),
    IconButton(
    icon: Icon(
    Icons.email,
    color: Colors.blueAccent,
    ),
    iconSize: 50.0,
    onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (c) => new ContactUs())),
    ),
    ],
    )),
    ),
    Expanded(
    child: GridView.count(
    primary: false,
    padding: const EdgeInsets.all(20.0),
    crossAxisSpacing: 30.0,
    mainAxisSpacing: 30.0,
    crossAxisCount: 4,
    children: <Widget>[
    FloatingActionButton(
    onPressed: null,
    backgroundColor: Colors.orange,
    child: Text('今天'),
    foregroundColor: Colors.black,
    ),
    FloatingActionButton(
    onPressed: null,
    backgroundColor: Colors.yellow,
    child: Text('年'),
    foregroundColor: Colors.black,
    ),

    ],
    ),
    )
    ],
    );











    share|improve this question
























      0












      0








      0







      My flutter app has a button to go to a contact page. It is working well when the GridView has only one floatingButton. But it will have error when the GridView has more than one floatingButton. Please help to solve this issue.



      Error:



      • flutter: The following assertion was thrown during a scheduler callback:

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

      • flutter: Within each subtree for which heroes are to be animated (typically a PageRoute subtree), each Hero

      • flutter: must have a unique non-null tag.

      • flutter: In this case, multiple heroes had the following tag:

      • flutter: Here is the subtree for one of the offending heroes:

      • flutter: # Hero(tag: , state: _HeroState#232b6)

      enter image description here



      class _DatabasePageState extends State<DatabasePage> 
      @override
      Widget build(BuildContext context)
      return Scaffold(
      backgroundColor: Colors.black,
      appBar: AppBar(
      title: Text('DB'),
      centerTitle: true,
      backgroundColor: Colors.black,
      ),
      body: _showOrderdatabase(),

      );


      Widget _showOrderdatabase()

      return Column(
      children: <Widget>[
      Container(
      height: 220.0,
      color: Colors.transparent,
      child: new Container(
      padding: EdgeInsets.all(40.0),
      decoration: new BoxDecoration(
      color: Colors.green,
      borderRadius: BorderRadius.all(const Radius.circular(40.0)),
      ),
      child: new Column(
      children: <Widget>[
      Text(
      "vds",
      style: TextStyle(fontSize: 16.0),
      ),
      IconButton(
      icon: Icon(
      Icons.email,
      color: Colors.blueAccent,
      ),
      iconSize: 50.0,
      onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (c) => new ContactUs())),
      ),
      ],
      )),
      ),
      Expanded(
      child: GridView.count(
      primary: false,
      padding: const EdgeInsets.all(20.0),
      crossAxisSpacing: 30.0,
      mainAxisSpacing: 30.0,
      crossAxisCount: 4,
      children: <Widget>[
      FloatingActionButton(
      onPressed: null,
      backgroundColor: Colors.orange,
      child: Text('今天'),
      foregroundColor: Colors.black,
      ),
      FloatingActionButton(
      onPressed: null,
      backgroundColor: Colors.yellow,
      child: Text('年'),
      foregroundColor: Colors.black,
      ),

      ],
      ),
      )
      ],
      );











      share|improve this question













      My flutter app has a button to go to a contact page. It is working well when the GridView has only one floatingButton. But it will have error when the GridView has more than one floatingButton. Please help to solve this issue.



      Error:



      • flutter: The following assertion was thrown during a scheduler callback:

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

      • flutter: Within each subtree for which heroes are to be animated (typically a PageRoute subtree), each Hero

      • flutter: must have a unique non-null tag.

      • flutter: In this case, multiple heroes had the following tag:

      • flutter: Here is the subtree for one of the offending heroes:

      • flutter: # Hero(tag: , state: _HeroState#232b6)

      enter image description here



      class _DatabasePageState extends State<DatabasePage> 
      @override
      Widget build(BuildContext context)
      return Scaffold(
      backgroundColor: Colors.black,
      appBar: AppBar(
      title: Text('DB'),
      centerTitle: true,
      backgroundColor: Colors.black,
      ),
      body: _showOrderdatabase(),

      );


      Widget _showOrderdatabase()

      return Column(
      children: <Widget>[
      Container(
      height: 220.0,
      color: Colors.transparent,
      child: new Container(
      padding: EdgeInsets.all(40.0),
      decoration: new BoxDecoration(
      color: Colors.green,
      borderRadius: BorderRadius.all(const Radius.circular(40.0)),
      ),
      child: new Column(
      children: <Widget>[
      Text(
      "vds",
      style: TextStyle(fontSize: 16.0),
      ),
      IconButton(
      icon: Icon(
      Icons.email,
      color: Colors.blueAccent,
      ),
      iconSize: 50.0,
      onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (c) => new ContactUs())),
      ),
      ],
      )),
      ),
      Expanded(
      child: GridView.count(
      primary: false,
      padding: const EdgeInsets.all(20.0),
      crossAxisSpacing: 30.0,
      mainAxisSpacing: 30.0,
      crossAxisCount: 4,
      children: <Widget>[
      FloatingActionButton(
      onPressed: null,
      backgroundColor: Colors.orange,
      child: Text('今天'),
      foregroundColor: Colors.black,
      ),
      FloatingActionButton(
      onPressed: null,
      backgroundColor: Colors.yellow,
      child: Text('年'),
      foregroundColor: Colors.black,
      ),

      ],
      ),
      )
      ],
      );








      gridview navigation flutter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 15:28









      GPH

      13412




      13412






















          1 Answer
          1






          active

          oldest

          votes


















          1














          FloatingActionButton has a heroTag property with the default value const _DefaultHeroTag(),.



          Since you have two FloatingActionButtons, you should assign a different tag for each of them:



           children: <Widget>[
          FloatingActionButton(
          onPressed: null,
          heroTag: 'Tag1',
          backgroundColor: Colors.orange,
          child: Text('今天'),
          foregroundColor: Colors.black,
          ),
          FloatingActionButton(
          onPressed: null,
          heroTag: 'Tag2',
          backgroundColor: Colors.yellow,
          child: Text('年'),
          foregroundColor: Colors.black,
          ),
          ],


          Or you could set both to null so no Hero widget is added to the tree.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265299%2fflutter-gridview-causes-navigator-push-error%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            FloatingActionButton has a heroTag property with the default value const _DefaultHeroTag(),.



            Since you have two FloatingActionButtons, you should assign a different tag for each of them:



             children: <Widget>[
            FloatingActionButton(
            onPressed: null,
            heroTag: 'Tag1',
            backgroundColor: Colors.orange,
            child: Text('今天'),
            foregroundColor: Colors.black,
            ),
            FloatingActionButton(
            onPressed: null,
            heroTag: 'Tag2',
            backgroundColor: Colors.yellow,
            child: Text('年'),
            foregroundColor: Colors.black,
            ),
            ],


            Or you could set both to null so no Hero widget is added to the tree.






            share|improve this answer



























              1














              FloatingActionButton has a heroTag property with the default value const _DefaultHeroTag(),.



              Since you have two FloatingActionButtons, you should assign a different tag for each of them:



               children: <Widget>[
              FloatingActionButton(
              onPressed: null,
              heroTag: 'Tag1',
              backgroundColor: Colors.orange,
              child: Text('今天'),
              foregroundColor: Colors.black,
              ),
              FloatingActionButton(
              onPressed: null,
              heroTag: 'Tag2',
              backgroundColor: Colors.yellow,
              child: Text('年'),
              foregroundColor: Colors.black,
              ),
              ],


              Or you could set both to null so no Hero widget is added to the tree.






              share|improve this answer

























                1












                1








                1






                FloatingActionButton has a heroTag property with the default value const _DefaultHeroTag(),.



                Since you have two FloatingActionButtons, you should assign a different tag for each of them:



                 children: <Widget>[
                FloatingActionButton(
                onPressed: null,
                heroTag: 'Tag1',
                backgroundColor: Colors.orange,
                child: Text('今天'),
                foregroundColor: Colors.black,
                ),
                FloatingActionButton(
                onPressed: null,
                heroTag: 'Tag2',
                backgroundColor: Colors.yellow,
                child: Text('年'),
                foregroundColor: Colors.black,
                ),
                ],


                Or you could set both to null so no Hero widget is added to the tree.






                share|improve this answer














                FloatingActionButton has a heroTag property with the default value const _DefaultHeroTag(),.



                Since you have two FloatingActionButtons, you should assign a different tag for each of them:



                 children: <Widget>[
                FloatingActionButton(
                onPressed: null,
                heroTag: 'Tag1',
                backgroundColor: Colors.orange,
                child: Text('今天'),
                foregroundColor: Colors.black,
                ),
                FloatingActionButton(
                onPressed: null,
                heroTag: 'Tag2',
                backgroundColor: Colors.yellow,
                child: Text('年'),
                foregroundColor: Colors.black,
                ),
                ],


                Or you could set both to null so no Hero widget is added to the tree.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 12 at 16:44

























                answered Nov 12 at 16:39









                chemamolins

                2,2791716




                2,2791716



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265299%2fflutter-gridview-causes-navigator-push-error%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    ReactJS Fetched API data displays live - need Data displayed static

                    政党