我在显示对话框时遇到问题。 当我向设备发送推送通知时,出现错误。但是音频播放,-->
assetsAudioPlayer.open(
Audio('sounds/alert.mp3'),
);
assetsAudioPlayer.play();
和第一个对话--->
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) => ProgressDialog(status: 'received trip..',),
);
我也能看到。
void fetchRideInfo(String rideID, context){
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) => ProgressDialog(status: '..',),
);
DatabaseReference rideRef = FirebaseDatabase.instance.reference().child('rideRequest/$rideID');
rideRef.once().then((DataSnapshot snapshot) {
Navigator.pop(context);
if(snapshot.value != null){
assetsAudioPlayer.open(
Audio('sounds/alert.mp3'),
);
assetsAudioPlayer.play();
double pickupLat = double.parse(snapshot.value["location"]["latitude"].toString()); //**error HERE**
double pickupLng = double.parse((snapshot.value["location"]["longitude"].toString()));
String pickupAddress = snapshot.value['pickup_address'].toString();
double destinationLat = double.parse(snapshot.value['destination']['latitude'].toString());
double destinationLng = double.parse(snapshot.value['destination']['longitude'].toString());
String destinationAddress = snapshot.value['destination_address'];
String paymentMethod = snapshot.value['payment_method'];
TripDetails tripDetails = TripDetails();
tripDetails.rideID = rideID;
tripDetails.pickupAddress = pickupAddress;
tripDetails.destinationAddress = destinationAddress;
tripDetails.pickup = LatLng(pickupLat , pickupLng);
tripDetails.destination = LatLng(destinationLat, destinationLng);
tripDetails.paymentMethod = paymentMethod;
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) => NotificationDialog(tripDetails: tripDetails,),
);
}
});
}
这是我的控制台
E/FlutterFcmService(11685): Fatal: failed to find callback
I/flutter (11685): ride_id: -MPRCo9pHbzEi1pOJOAs
E/flutter (11685): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The method '[]' was called on null.
E/flutter (11685): Receiver: null
E/flutter (11685): Tried calling: []("latitude")
E/flutter (11685): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
E/flutter (11685): #1 PushNotificationService.fetchRideInfo.<anonymous closure> (package:cab_driver/helpers/pushnotificationservice.dart:82:68)
E/flutter (11685): #2 _rootRunUnary (dart:async/zone.dart:1194:47)
E/flutter (11685): #3 _CustomZone.runUnary (dart:async/zone.dart:1097:19)
E/flutter (11685): #4 _FutureListener.handleValue (dart:async/future_impl.dart:150:18)
E/flutter (11685): #5 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:703:45)
E/flutter (11685): #6 Future._propagateToListeners (dart:async/future_impl.dart:732:32)
E/flutter (11685): #7 Future._completeWithValue (dart:async/future_impl.dart:536:5)
E/flutter (11685): #8 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:254:13)
E/flutter (11685): #9 Query.once (package:firebase_database/src/query.dart)
E/flutter (11685): <asynchronous suspension>
E/flutter (11685):
我没有找到任何关于此的信息。许多关于 NoSuchMethodError 的解决方案,但如何实现我的问题?我不知道。请帮忙。