Flutter Firebase realtime once()。then()在重新运行时不会更新[关闭]

问题描述 投票:0回答:1

Flutter Firebase realtime once()。then()在重新运行时不会更新

当我使用once.then读取数据,如果我再次运行它不会更新变量或给出null

firebase firebase-realtime-database dart flutter
1个回答
1
投票

once()方法正是它的名字所暗示的:它只读取一次数据,而不监视更新。正如documentation所说:

侦听单个值事件,然后停止侦听。

要获得实时更新,请使用其中一个on...流,例如onValue

更新此位置的数据时触发。

© www.soinside.com 2019 - 2024. All rights reserved.