当 Stream 将触发新事件时无法读取节点更改。火力地堡数据库 v9
Unable to read node changes when the Stream will fire a new event. firebase database v9
适用于 firebase 数据库 v8,但不适用于 v9。从我从其他用户那里读到的-Firebase v9,他们从使用动态转向了对象? .
我无法在我的代码中实施更改。
你能看看吗?更多关于这个
StreamSubscription<DatabaseEvent>? rideStreamSubscription;
rideStreamSubscription = rideRequestRef!.onValue.listen((DatabaseEvent event) async {
if (event.snapshot.value["car_details"] != null) {
carDetailsDriver = (event.snapshot.value["car_details"].toString());
Provider.of<AppData>(context, listen: false)
.carDetailsDriverMainScreen(carDetailsDriver);
if (event.snapshot.value!["driver_id"] != null) {
rideReqAcceptDriver =
(event.snapshot.value["driver_id"].toString());
print("rideReqAcceptDriver $rideReqAcceptDriver");
}
}
错误在 event.snapshot.value["car_details"]
The method '[]' can't be unconditionally invoked because the receiver can be 'null'.
Try making the call conditional (using '?.') or adding a null check to the target ('!')
以及 event.snapshot.value!["driver_id"]
The operator '[]' isn't defined for the type 'Object'.
Try defining the operator '[]'
试试这个。
StreamSubscription<DatabaseEvent>? rideStreamSubscription;
rideStreamSubscription = rideRequestRef!.onValue.listen((DatabaseEvent event) async {
dynamic data = event.snapshot.value;
if (data["car_details"] != null) {
carDetailsDriver = (data["car_details"].toString());
Provider.of<AppData>(context, listen: false)
.carDetailsDriverMainScreen(carDetailsDriver);
if (data["driver_id"] != null) {
rideReqAcceptDriver =
(data["driver_id"].toString());
print("rideReqAcceptDriver $rideReqAcceptDriver");
}
}
适用于 firebase 数据库 v8,但不适用于 v9。从我从其他用户那里读到的-Firebase v9,他们从使用动态转向了对象? .
我无法在我的代码中实施更改。
你能看看吗?更多关于这个
StreamSubscription<DatabaseEvent>? rideStreamSubscription;
rideStreamSubscription = rideRequestRef!.onValue.listen((DatabaseEvent event) async {
if (event.snapshot.value["car_details"] != null) {
carDetailsDriver = (event.snapshot.value["car_details"].toString());
Provider.of<AppData>(context, listen: false)
.carDetailsDriverMainScreen(carDetailsDriver);
if (event.snapshot.value!["driver_id"] != null) {
rideReqAcceptDriver =
(event.snapshot.value["driver_id"].toString());
print("rideReqAcceptDriver $rideReqAcceptDriver");
}
}
错误在 event.snapshot.value["car_details"]
The method '[]' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!')
以及 event.snapshot.value!["driver_id"]
The operator '[]' isn't defined for the type 'Object'. Try defining the operator '[]'
试试这个。
StreamSubscription<DatabaseEvent>? rideStreamSubscription;
rideStreamSubscription = rideRequestRef!.onValue.listen((DatabaseEvent event) async {
dynamic data = event.snapshot.value;
if (data["car_details"] != null) {
carDetailsDriver = (data["car_details"].toString());
Provider.of<AppData>(context, listen: false)
.carDetailsDriverMainScreen(carDetailsDriver);
if (data["driver_id"] != null) {
rideReqAcceptDriver =
(data["driver_id"].toString());
print("rideReqAcceptDriver $rideReqAcceptDriver");
}
}