I tried the exact same step as mentioned in the tutorial as well.
Future makeCall({Call call}) async {
try {
print("line 1" + call.callerId);
print("line 1" + call.receiverId);
call.hasDialled = true;
print("call.hasDialled set to true");
Map<String, dynamic> hasDialledMap = call.toMap(call);
print(hasDialledMap);
call.hasDialled = false;
print("call.hasDialled set to true");
Map<String, dynamic> hasNotDialledMap = call.toMap(call);
print(hasNotDialledMap);
await Firestore.instance.collection(CALL_COLLECTION)
.document(call.callerId)
.setData(hasDialledMap);
print("call object for caller has been set");
await Firestore.instance.collection(CALL_COLLECTION)
.document(call.receiverId)
.setData(hasNotDialledMap);
print("call object for receiver has been set");
return true;
} catch (e) {
print("madarchod firestore mein kuch problemwa hai");
return false;
}
The same way my call.dart is :
class Call {
String callerId;
String callerName;
String receiverId;
String receiverName;
String channelId;
bool hasDialled;
Call({
this.callerId,
this.callerName,
// this.callerPic,
this.receiverId,
this.receiverName,
// this.receiverPic,
this.channelId,
this.hasDialled,
});
Map<String, dynamic> toMap(Call call) {
Map<String, dynamic> callMap = Map();
callMap["caller_id"] = call.callerId;
callMap["caller_name"] = call.callerName;
// callMap["caller_pic"] = call.callerPic;
callMap["receiver_id"] = call.receiverId;
callMap["receiver_name"] = call.receiverName;
// callMap["receiver_pic"] = call.receiverPic;
callMap["channel_id"] = call.channelId;
callMap["hasDialled"] = call.hasDialled;
}
Call.fromMap(Map callMap) {
this.callerId = callMap["caller_id"];
this.callerName = callMap["caller_name"];
// this.callerPic = callMap["caller_pic"];
this.receiverId = callMap["receiver_id"];
this.receiverName = callMap["receiver_name"];
// this.receiverPic = callMap["receiver_pic"];
this.channelId = callMap["channel_id"];
this.hasDialled = callMap["hasDialled"];
}
}
Call_utilities file:
import 'package:docapp/screens/callscreens/call_screen.dart';
import 'package:flutter/material.dart';
import 'package:docapp/resources/call_methods.dart';
import 'package:docapp/models/user.dart';
import 'package:docapp/models/call.dart';
import 'dart:math';
class CallUtils {
static final CallMethods callMethods = CallMethods();
static dial({String senderName, User from, User to, context}) async {
print("sender name is " + senderName);
print("sender uid is " + from.uid);
print("receiver uid is" + to.uid);
print("receiver name is " + to.name);
Call call = Call(
callerId: from.uid,
callerName: senderName,
// callerPic: from.profilePhoto,
receiverId: to.uid,
receiverName: to.name,
// receiverPic: to.profilePhoto,
channelId: Random().nextInt(1000).toString(),
);
bool callMade = await callMethods.makeCall(call: call);
if(callMade) {
print("callMade tak gaya");
} else {
print("call utils mein atak gaya");
}
call.hasDialled = true;
if(callMade) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CallScreen(call: call),
));
}
}
}
the error log :
I/flutter ( 4548): sender name is abcdef
I/flutter ( 4548): sender uid is eKsPXt5Nr4bkxYFW7SPaRXL4xh23
I/flutter ( 4548): receiver uid isaLSb7ebMfsfAxybrwq21kXjkcJM2
I/flutter ( 4548): receiver name is abhishek
I/flutter ( 4548): line 1eKsPXt5Nr4bkxYFW7SPaRXL4xh23
I/flutter ( 4548): line 1aLSb7ebMfsfAxybrwq21kXjkcJM2
I/flutter ( 4548): line 1abcdef
I/flutter ( 4548): line 1abhishek
I/flutter ( 4548): call.hasDialled set to true
I/flutter ( 4548): null
I/flutter ( 4548): call.hasDialled set to true
I/flutter ( 4548): null
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): Failed to handle method call
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): java.lang.NullPointerException: Provided data must not be null.
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at b.d.c.a.j.a(:906)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at com.google.firebase.firestore.h.a(:161)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at com.google.firebase.firestore.h.a(:146)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at io.flutter.plugins.firebase.cloudfirestore.a.onMethodCall(:872)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at c.a.b.a.j$a.a(:226)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at io.flutter.embedding.engine.e.b.a(:85)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(:631)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at android.app.ActivityThread.main(ActivityThread.java:6541)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 4548): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
I/flutter ( 4548): madarchod firestore mein kuch problemwa hai
I/flutter ( 4548): call utils mein atak gaya