I have a problem with my ListView, essentially what I would like to do is an interactable ListTile. I would like the user to click on the tile and via navigator move them to another page.
Something like this works with buttons (onPressed) but doesn't work with ListTiles:
Navigator.of(context).pushNamed(HomePage.tag);
I've tried using OnTap but I can't figure out a way of using that.
final list = ListView(
children: <Widget>[
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Barrack Obama'),
),
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Neil Armstrong'),
onTap: ,
),
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Ivan Ivanovich Ivanov'),
),
],
);
The list itself is very simple and a test, I'm trying to redirect users when they click on the tile via navigator.
This should work
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Neil Armstrong'),
onTap: (){
Navigator.of(context).pushNamed("your_route_name");
} ,
),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.