firebase-realtime-database - 如何在firebase上推送新 key ?

标签 firebase-realtime-database dart flutter

亲爱的,

我不知道如何将他的新 key 插入火力基地。
这是我的简单示例代码:

FirebaseDatabase.instance.reference().child('mychild').push().set(
            <String, String>{
              'hello': 'world',
            });

我怎样才能得到这个元素的键被推送?

谢谢

最佳答案

你可以试试这个:

DatabaseReference rootRef = FirebaseDatabase.instance.reference(); 
String newkey = rootRef.child('mychild').push().key;
rootRef.child('mychild').child(newKey).set(<String, String>{'hello': 'world',});

关于firebase-realtime-database - 如何在firebase上推送新 key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53682732/

相关文章:

firebase - 使用 angularfire2 在 firebase 数据库中获取时间

visual-studio - 注释或删除代码后,VS Code( flutter , Dart )错误不会消失

flutter - 如何在 dart 中创建多个构造函数?

flutter - 如何在应用内获取 Dart 和 Flutter 版本

javascript - Firebase 数据库 : how to resolve a Promise and keep listening to Firebase DB changes

ios - 从另一个 Firebase 应用获取 Firebase 数据库

android - 检查 Firebase android 中的最后一个 child 是否

bluetooth - FlutterBlue 特性

templates - 在 polymer Dart 中,我如何在重复模板中计数

flutter - 我如何为与 Provider 一起工作的列表实现 ChangeNotifier?