import 'package:flutter/material.dart';
import 'package:ui_mvc/Rings.dart';
class Diamonds extends StatefulWidget {
@override
_DiamondsState createState() => _DiamondsState();
}
class _DiamondsState extends State<Diamonds> {
var dataList= [
{
"name": "A1",
"image":"assets/1.jpg" ,
"location": "Delhi",
},
{
"name": "A2",
"image": "assets/2.jpg" ,
"location": "Delhi",
},
{
"name": "A3",
"image": "assets/3.jpg" ,
"location": "Delhi",
},
{
"name": "A4",
"image": "assets/4.jpg" ,
"location": "Delhi",
},
{
"name": "A5",
"image": "assets/5.jpg" ,
"location": "Delhi",
},
];
@override
Widget build(BuildContext context) {
return GridView.builder(
scrollDirection: Axis.horizontal,
itemCount: dataList.length,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 1),
itemBuilder: (BuildContext context,int index){
return SingleProd(
prodName: dataList[index]['name'],
prodImage: dataList[index]['image'],
prodLocation: dataList[index]['location'],
);
});
}
}
class SingleProd extends StatelessWidget {
final prodName;
final prodImage;
final prodLocation;
SingleProd({
this.prodName,
this.prodImage,
this.prodLocation,
});
@override
Widget build(BuildContext context) {
return Card(
child: Hero(
tag: prodName,
child: Material(
child: InkWell(
onTap: ()=>
Navigator.of(context).push(
new MaterialPageRoute(builder: (context)=> new Rings())
),
child: GridTile(
footer: Container(
color: Colors.white,
child: ListTile(
title: Text(
prodName,
textAlign: TextAlign.left,
),
subtitle: Text(
prodLocation,
textAlign: TextAlign.left,
),
),
),
child: Image.asset(
prodImage,
fit: BoxFit.fitHeight)
),
),
)
),
);
}
}
So I'm trying to display a horizontal list with 5 tiles. I want each tile to redirect to the same page (for the time being) that's why I call Rings() which is defined in another page. And upon tapping one of the tiles the screen goes black. But it just keeps on showing me this error: 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. In this case, multiple heroes had the following tag: A
Here is the subtree for one of the offending heroes: Hero tag: A state: _HeroState#d0a27 When the exception was thrown, this was the stack:
FloatingActionButton
s defined somewhere? I tried your sample code and it works fine for me. – guggeFloatingActionButton
in my entire project but still getting this error when I navigate from child to parent screen. Please suggest me what is the solution? Thanks a lot. – Kamlesh