假设我在Cloud Firestore中创建了一个文档,并且希望在创建数据5分钟后更改该数据。 我该如何在dart(framework:flutter)中完成这项工作。
预先感谢
答案 0 :(得分:1)
如果您希望在特定时间更新Firestore文档,则可以考虑使用scheduled Cloud Functions。这种更新文档的方法会创建一个Google Cloud Pub / Sub主题和Cloud Scheduler来触发有关该主题的事件,从而确保您的功能按预期的时间表运行。
答案 1 :(得分:0)
您可以使用Timer在特定时间后更新数据。
Timer _timer;
int _start = 10;
void startTimer() {
const oneSec = const Duration(seconds: 1);
_timer = new Timer.periodic(
oneSec,
(Timer timer) => setState(
() {
if (your logic) {
//Your code
} else {
//Your code
}
},
),
);
}