Reputation: 1780
I have a list of items and i want when the user click on an item, appear another window, i write the code as shown bellow
return ListTile( leading: Container(
padding: EdgeInsets.only(left: 8.0 , top: 8.0 ,bottom: 8.0),
child: Column(
children: <Widget>[
_buildGymLocationRow(gym), // method
SizedBox(height: 5.0,),
_builDescrRateRow(gym), ], ), )
,onTap: (){ Navigator.push( context, new MaterialPageRoute(builder: (context) => new gymDetails()));
},
);
but when i click on the item or ListTile, it's show me this error.. i don't know what i have to do.. please I need help
I/flutter ( 9134): Another exception was thrown: NoSuchMethodError: The method 'ancestorStateOfType' was called on null.
Upvotes: 0
Views: 1152
Reputation: 10453
The error NoSuchMethodError: The method 'ancestorStateOfType' was called on null.
thrown is most likely caused by the widget having been removed from the tree. It's possible that it doesn't have a context anymore. To solve this issue, you may want to consider keeping track of the BuildContext context
that you're using by storing it as a variable or passing it as a parameter.
Upvotes: 2