我正在尝试最新版本的 Firebase-Dart (0.5.0),并尝试使用 Dart 库复制 JavaScript Firebase 聊天教程 ( https://www.firebase.com/tutorial/#example/chat )。
我尝试使用库的push
功能,如下所示:
f = new Firebase('https://uniqueID.firebaseio-demo.com/');
f.push(value: {
'name': 'John',
'text': 'hello again'
});
但是数据没有被存储。我做错了什么?
最佳答案
在查看 firebase dart 包装器 git repo 中的测试文件后,我发现了这个:
test('push', () {
// TODO: actually validate the result
var pushRef = f.push();
return pushRef.set('HAHA');
});
总而言之,我认为您需要进行推送,然后设置它的值:
f = new Firebase('https://uniqueID.firebaseio-demo.com/');
var pushRef = f.push();
pushRef.set("{'name': 'John','text': 'hello again'}");
请在此处查看 firebase 包测试脚本:https://github.com/firebase/firebase-dart/blob/master/test/test.dart
关于dart - 如何在 Firebase-Dart 中推送?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29140887/