0

I have a problem with showing dialog. When i'm sending push notofication to the device i have error. But the audio play, -->

 assetsAudioPlayer.open(
      Audio('sounds/alert.mp3'),
    );
    assetsAudioPlayer.play();

and first dialog --->

showDialog(
    barrierDismissible: false,
    context: context,
    builder: (BuildContext context) => ProgressDialog(status: 'received trip..',),

);

i also can see.

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,),

    );
  }

});

}

THIS MY CONSOLE

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):

I dont find any information about this. Many solution about NoSuchMethodError, but HOW implement to my PROBLEM? I dont know. Please help.

Nikita
  • 1
  • 1
    Does this answer your question? [What is a NoSuchMethod error and how do I fix it?](https://stackoverflow.com/questions/64049102/what-is-a-nosuchmethod-error-and-how-do-i-fix-it) – nvoigt Dec 26 '20 at 11:20
  • Obviously `snapshot.value["location"]` returned `null`. Why that is is up to you to figure out. It's called "debugging". Start your debugger and inspect all your variables. – nvoigt Dec 26 '20 at 11:22

0 Answers0