简体   繁体   中英

Flutter how to filter my LISTTILEVIEW in the second screen with the ID recovered in the first screen

I get the ID. but I don't know how to use it on the second screen. I want to filter my new list with the ID recovered in the first screen

 @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Chapitres'),
        backgroundColor: Colors.orange[600],
      ),
      drawer: DrawerNavigation(),
      body: ListView.builder(
          itemCount: _chapitreList.length,
          itemBuilder: (context, index){
        return Card(
          child: Padding(
            padding: const EdgeInsets.all(12.0),
            child: ListTile(
              leading: IconButton(icon: Icon(Icons.gavel),onPressed:(){} ),
              title: Row(
                children: <Widget>[
                  Text(_chapitreList[index].chapitre, style: new TextStyle(fontSize: 15),),
                ],
              ),
              onTap: (){},
              subtitle: Text(_chapitreList[index].titre, style: new TextStyle(fontSize: 10),),
            ),
          ),
        );
      }),

You can pass arguments when Navigate:

Navigator.of(context).pushNamed(YourRoute, arguments: //Here you can pass the id)

And in the second screen:

final String YOURID = ModalRoute.of(context).settings.arguments;

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM