i created a listview in which i used the gero widget i have wrapped all the hero widgets and listview widgets in material but still I get this error and when i click the listtile it works properly but when I come to the second page I am not able to go back
homepage:
body: Material(
child: ListView(
children: [
Hero(
tag: nyc_img,
child: ListTile(
leading: Image.network(
nyc_img,
height: 100,
width: 100,
),
title: Text("New York City"),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => NYCpage()),
);
},
),
),
],
),
second page:
body: Center(
child: Material(
type: MaterialType.transparency,
child: Hero(
tag: nyc_img,
child: Image.network(nyc_img),
),
),
),
2
Answers
Wrap your
ListTile
with Material widget to solve this.You need to Wrap the child of your
Hero
widget in aMaterial
as the animated part is getting called outside of Scaffold widget so you need to pass Material widget separatelyfor the Second page