更新数据后如何保存列表视图的位置
How can I save position of my listview after updated data
我的问题是当我更新数据时 listview
再次回到页面顶部。我想在 listview
中保存 post 个位置。我不能使用 set state 顺便说一句,因为 listview
进入第零个索引,但它应该进入第六个索引。我怎样才能做到这一点?我的代码如下:
FirebaseFirestore.instance.collection('Users')
.doc(auth.currentUser!.uid)
.update(
{
'begendikleri': begenenler,
},
);
不知道我是否理解的很清楚。您可以做的只是在更新后使用 Navigator.pop 从屏幕 2 到屏幕 1,然后在屏幕 1 上使用 then 刷新项目。
示例:
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Page2())).then((value) {
// you can call SetState or your update list method here
setState(() {
});
});
我的问题是当我更新数据时 listview
再次回到页面顶部。我想在 listview
中保存 post 个位置。我不能使用 set state 顺便说一句,因为 listview
进入第零个索引,但它应该进入第六个索引。我怎样才能做到这一点?我的代码如下:
FirebaseFirestore.instance.collection('Users')
.doc(auth.currentUser!.uid)
.update(
{
'begendikleri': begenenler,
},
);
不知道我是否理解的很清楚。您可以做的只是在更新后使用 Navigator.pop 从屏幕 2 到屏幕 1,然后在屏幕 1 上使用 then 刷新项目。
示例:
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Page2())).then((value) {
// you can call SetState or your update list method here
setState(() {
});
});