Home > Enterprise >  How can I save position of my listview after updated data
How can I save position of my listview after updated data

Time:09-22

My problem is the listview goes to top of the page again when I updated data. I want to save post position in listview. I can’t use set state btw because listview goes to zeroth index but it should go to sixth for example. How can I do that? My code is below:

FirebaseFirestore.instance.collection('Users')
.doc(auth.currentUser!.uid)
.update(
    {
        'begendikleri': begenenler,
    },
); 

CodePudding user response:

I don't know if I understand very well. What you can do is simply use a Navigator.pop from screen 2 to screen 1 after updating and, on screen 1, use the then to refresh the items.

Example:

Navigator.of(context).push(MaterialPageRoute(builder: (context) => Page2())).then((value) {
   // you can call SetState or your update list method here
   setState(() {
    
   });
});
  • Related