dart - 如何在 Firebase-Dart 中推送?

标签 dart firebase

我正在尝试最新版本的 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/

相关文章:

dart - 如何在 BottomNavigationBarItem 中绝对定位徽章

unit-testing - Flutter: 'package:shared_preferences/shared_preferences.dart':断言失败:第 33 行 pos 16: 'key.startsWith(_prefix)':不正确

java - FirebaseMessagingService 如何在登录 Activity 后启动

android - 在 google play store 上上传 apk 后,React native 应用程序崩溃,它仅在第一次崩溃

firebase - Firestore 安全规则 - 如何使用变量作为字段名称?

node.js - 如何确保在 ElasticSearch Bonsai 免费实例中使用 Firebase FlashLight 索引每个对象

firebase - 在 initState() 中放置两个 Firestore.instances

dart - flutter/模拟。使用 mockito 测试 API 提供程序,api header 有问题

android - 尝试在Flutter中使用Animator时发生编译错误

android - Flutter - TextFormField 上的键盘