【问题标题】:How can I save position of my listview after updated data更新数据后如何保存列表视图的位置
【发布时间】:2021-11-09 04:41:32
【问题描述】:

我的问题是,当我更新数据时,listview 又回到了页面顶部。我想将帖子位置保存在listview。顺便说一句,我不能使用 set state,因为listview 会转到第 0 个索引,但它应该会转到第 6 个索引。我怎样才能做到这一点?我的代码如下:

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

【问题讨论】:

  • 添加列表视图的代码,以便我们看到您的实现。

标签: firebase flutter listview google-cloud-firestore


【解决方案1】:

我不知道我是否理解得很好。您可以做的只是在更新后使用从屏幕 2 到屏幕 1 的 Navigator.pop,然后在屏幕 1 上使用 then 刷新项目。

例子:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-03
    相关资源
    最近更新 更多