Firebase_db_web_unofficial 依赖
Firebase_db_web_unofficial dependency
我正在尝试从 web flutter 中将数据输入到 Firebase RealTime 数据库中,发现 Firebase_db_web_unofficial 依赖项可以很好地更新和删除,但是当我尝试添加新记录时,我遇到了麻烦并且我不知道如何添加注册表项,这样做会出现错误。
这是我正在使用的代码
void save() {
String _codeTMP = _codeController.text;
FirebaseDatabaseWeb.instance
.reference()
.child("Admin")
.child("Country")
.child('$_codeTMP')
.set({
"name": _nameController.text,
"currency_code": _currencyController.text,
"base_fare": _baseFareController.text,
"per_km": _perKmController.text,
"per_minute": _perMinuteController.text,
});
}
变量_codeTMP包含我追加的信息的主键,也就是说,它还不存在,我正在与对象一起创建它
enter image description here
它抛出的错误如下。
NoSuchMethodError: method not found: 'a' on null
js_primitives.dart:47 at a9E.[=12=] (http://localhost:56272/main.dart.js:67183:17)
js_primitives.dart:47 at zj.Hk (http://localhost:56272/main.dart.js:39769:16)
js_primitives.dart:47 at Object.eval (eval at akO (http://localhost:56272/main.dart.js:3127:8), <anonymous>:3:55)
js_primitives.dart:47 at fo.MU (http://localhost:56272/main.dart.js:38004:9)
js_primitives.dart:47 at fo.ew (http://localhost:56272/main.dart.js:38009:30)
js_primitives.dart:47 at fo.MH (http://localhost:56272/main.dart.js:38160:14)
js_primitives.dart:47 at fo.FC (http://localhost:56272/main.dart.js:38136:3)
js_primitives.dart:47 at fo.MF (http://localhost:56272/main.dart.js:38099:3)
js_primitives.dart:47 at fo.j7 (http://localhost:56272/main.dart.js:38064:16)
js_primitives.dart:47 at Object.eval (eval at akO (http://localhost:56272/main.dart.js:3131:8), <anonymous>:3:37)
如果有人可以帮助我解决这个错误,或者有其他方法可以使用 Firebase Database RealTime 处理 web flutter,我非常感谢你的帮助。
使用 update()
方法代替 set()
。
我正在尝试从 web flutter 中将数据输入到 Firebase RealTime 数据库中,发现 Firebase_db_web_unofficial 依赖项可以很好地更新和删除,但是当我尝试添加新记录时,我遇到了麻烦并且我不知道如何添加注册表项,这样做会出现错误。
这是我正在使用的代码
void save() {
String _codeTMP = _codeController.text;
FirebaseDatabaseWeb.instance
.reference()
.child("Admin")
.child("Country")
.child('$_codeTMP')
.set({
"name": _nameController.text,
"currency_code": _currencyController.text,
"base_fare": _baseFareController.text,
"per_km": _perKmController.text,
"per_minute": _perMinuteController.text,
});
}
变量_codeTMP包含我追加的信息的主键,也就是说,它还不存在,我正在与对象一起创建它
enter image description here
它抛出的错误如下。
NoSuchMethodError: method not found: 'a' on null
js_primitives.dart:47 at a9E.[=12=] (http://localhost:56272/main.dart.js:67183:17)
js_primitives.dart:47 at zj.Hk (http://localhost:56272/main.dart.js:39769:16)
js_primitives.dart:47 at Object.eval (eval at akO (http://localhost:56272/main.dart.js:3127:8), <anonymous>:3:55)
js_primitives.dart:47 at fo.MU (http://localhost:56272/main.dart.js:38004:9)
js_primitives.dart:47 at fo.ew (http://localhost:56272/main.dart.js:38009:30)
js_primitives.dart:47 at fo.MH (http://localhost:56272/main.dart.js:38160:14)
js_primitives.dart:47 at fo.FC (http://localhost:56272/main.dart.js:38136:3)
js_primitives.dart:47 at fo.MF (http://localhost:56272/main.dart.js:38099:3)
js_primitives.dart:47 at fo.j7 (http://localhost:56272/main.dart.js:38064:16)
js_primitives.dart:47 at Object.eval (eval at akO (http://localhost:56272/main.dart.js:3131:8), <anonymous>:3:37)
如果有人可以帮助我解决这个错误,或者有其他方法可以使用 Firebase Database RealTime 处理 web flutter,我非常感谢你的帮助。
使用 update()
方法代替 set()
。