flutter GridView causes Navigator.push error
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)
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
add a comment |
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)
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
add a comment |
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)
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
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)
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
gridview navigation flutter
asked Nov 12 '18 at 15:28
GPHGPH
14412
14412
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
FloatingActionButton
has a heroTag
property with the default value const _DefaultHeroTag(),
.
Since you have two FloatingActionButton
s, 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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
FloatingActionButton
has a heroTag
property with the default value const _DefaultHeroTag(),
.
Since you have two FloatingActionButton
s, 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.
add a comment |
FloatingActionButton
has a heroTag
property with the default value const _DefaultHeroTag(),
.
Since you have two FloatingActionButton
s, 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.
add a comment |
FloatingActionButton
has a heroTag
property with the default value const _DefaultHeroTag(),
.
Since you have two FloatingActionButton
s, 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.
FloatingActionButton
has a heroTag
property with the default value const _DefaultHeroTag(),
.
Since you have two FloatingActionButton
s, 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.
edited Nov 12 '18 at 16:44
answered Nov 12 '18 at 16:39
chemamolinschemamolins
2,4841817
2,4841817
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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