我试图通过使用 transaction . 我确实喜欢。
transaction
void _runTransaction(DatabaseReference ref, Map<String, dynamic> data) async { await ref.runTransaction((MutableData tx) async { tx.value = data; return tx; }); }
但应用程序将崩溃,孩子将不会被创建。 我做错了吗? 有人知道哪里出了问题吗?
正如文件所说 performs an optimistic-concurrency transactional update to the data at this Firebase Database location.
performs an optimistic-concurrency transactional update to the data at this Firebase Database location.
我认为你不能用交易来创造。 创建子项后,使用事务处理更新它。