# 'java.util.List org.webrtc.PeerConnection.getTransceivers()' on a null object reference"
I am creating a screen mirroring application using twilio as a turn server with web rtc. When I call mirrorScreen()
The error: Attempt to invoke virtual method 'java.util.List org.webrtc.PeerConnection.getTransceivers()' on a null object reference arises. In order to trace the execution I added several print statements but none of these are executing.
Here is my code:
mirrorScreen() async {
FlutterBackground.enableBackgroundExecution();
RTCPeerConnection connect =
await _createPeerConnection().then((conn) {
print(
'connected---------------------------------------------------------------------- successfully');
inspect(conn);
return conn;
});
print('connnnnnnnnnnnected');
}
_createPeerConnection() async {
try {
Map<String, dynamic> config = {
"iceServers": [
{
'url': 'turn:global.turn.twilio.com:3478?transport=tcp',
'username': 'Test SID',
'credentials': 'Test Auth Token'
},
],
};
final Map<String, dynamic> offerSdpConstraints = {
"mandatory": {
"OfferToReceiveAudio": true,
"OfferToReceiveVideo": true,
},
"optional": [],
};
RTCPeerConnection pc =
await createPeerConnection(config, offerSdpConstraints);
return pc;
} catch (e) {
print('errro');
}
}
P.s Neither of the print statement is executing