diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index 0fd54e74..a951e071 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -1,3 +1,5 @@ +import 'package:diplomaticquarterapp/voipcall/model/get_user_login_token.dart'; + class AppState { static final AppState _instance = AppState._internal(); @@ -10,4 +12,35 @@ class AppState { set setLogged(v) => isLogged = v; bool get getIsLogged => isLogged; + + // Calling + UserAutoLoginModel? chatDetails; + + set setchatUserDetails(UserAutoLoginModel details) => chatDetails = details; + + UserAutoLoginModel get getchatUserDetails => chatDetails!; + + String _iosVoipPlayerID = ""; + + String get iosVoipPlayerID => _iosVoipPlayerID; + + set setiosVoipPlayerID(String value) { + _iosVoipPlayerID = value; + } + + bool _isUserOnline = false; + + bool get getisUserOnline => _isUserOnline; + + set setisUserOnline(bool value) { + _isUserOnline = value; + } + + bool _isBackgroundCall = false; + + bool get isBackgroundCall => _isBackgroundCall; + + set isBackgroundCall(bool value) { + _isBackgroundCall = value; + } } diff --git a/lib/voipcall/call/chat_incoming_call_screen.dart b/lib/voipcall/call/chat_incoming_call_screen.dart index cec8a2ee..f8b85a58 100644 --- a/lib/voipcall/call/chat_incoming_call_screen.dart +++ b/lib/voipcall/call/chat_incoming_call_screen.dart @@ -4,11 +4,11 @@ import 'dart:io'; import 'dart:ui'; import 'package:diplomaticquarterapp/app_state/app_state.dart'; -import 'package:diplomaticquarterapp/models/chat/call.dart'; -import 'package:diplomaticquarterapp/models/chat/incoming_call_model.dart'; import 'package:diplomaticquarterapp/voipcall/consts.dart'; +import 'package:diplomaticquarterapp/voipcall/model/call.dart'; import 'package:diplomaticquarterapp/voipcall/model/get_single_user_chat_call.dart'; import 'package:diplomaticquarterapp/voipcall/model/get_user_login_token.dart'; +import 'package:diplomaticquarterapp/voipcall/model/incoming_call_model.dart'; import 'package:diplomaticquarterapp/voipcall/provider/chat_call_provider.dart'; import 'package:draggable_widget/draggable_widget.dart'; import 'package:flutter/foundation.dart'; @@ -20,7 +20,7 @@ import 'package:provider/provider.dart'; bool isCallConnected = false; class StartCallPage extends StatefulWidget { - IosCallPayload payload; + IosCallPayload? payload; StartCallPage({this.payload}); @@ -30,7 +30,7 @@ class StartCallPage extends StatefulWidget { class _StartCallPageState extends State { DragController dragController = DragController(); - ChatCallProvider cProv; + ChatCallProvider? cProv; @override void initState() { @@ -43,21 +43,21 @@ class _StartCallPageState extends State { } void startCall() async { - IncomingCallModel sessionData; + IncomingCallModel? sessionData; // dynamic calls = await FlutterCallkitIncoming.activeCalls(); // if (calls.isNotEmpty) { // sessionData.extra.callerDetails = {"id":341682,"userName":"Aamir.Muhammad","email":"Aamir.Muhammad@cloudsolutions.com.sa","phone":null,"title":"Aamir Saleem Ahmad Dost Muhammad","token":"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIzNDE2ODIiLCJlbWFpbCI6IkFhbWlyLk11aGFtbWFkQGNsb3Vkc29sdXRpb25zLmNvbS5zYSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvdXNlcmRhdGEiOiJBYW1pci5NdWhhbW1hZCIsIm5iZiI6MTcwNzIwNTAyMywiZXhwIjoxNzA3MjkxNDIzLCJpYXQiOjE3MDcyMDUwMjN9.Zz2bcsMwiLAAWGZh2E_p5Qs6ItMt0JHhDFI_0DLdggCQtt6HHcT4n8nvqMZx-uYr3jLwqhA_IAjTuaCeSE15sw","isDomainUser":true,"isActiveCode":false,"encryptedUserId":"nn7RkYzbnQc=","encryptedUserName":"/QruOyp4QMcmNXKZlljUgg=="}; // sessionData = IncomingCallModel.fromRawJson(jsonEncode(calls[0])); if (kDebugMode) { - print(sessionData.toRawJson()); + print(sessionData!.toRawJson()); } - if (cProv.isUserOnline) { + if (cProv!.isUserOnline) { AppState().isBackgroundCall = true; if (kDebugMode) { print("====== Processing Incoming Call in Online State ========="); } - await cProv.startIncomingCallViaKit(inCallData: sessionData.extra.callerDetails.toJson(), isVCall: sessionData.extra.callType == "video" ? true : false); - cProv.init(); + await cProv!.startIncomingCallViaKit(inCallData: sessionData!.extra!.callerDetails!.toJson(), isVCall: sessionData.extra!.callType == "video" ? true : false); + cProv!.init(); isCallConnected = true; } else { AppState().isBackgroundCall = true; @@ -65,11 +65,11 @@ class _StartCallPageState extends State { print("====== Processing Incoming Call ========="); } // cProv.isUserOnline = provider.isUserOnline; - await cProv.startIncomingCallViaKit(inCallData: sessionData.extra.callerDetails.toJson(), isVCall: sessionData.extra.callType == "video" ? true : false); + await cProv!.startIncomingCallViaKit(inCallData: sessionData!.extra!.callerDetails!.toJson(), isVCall: sessionData!.extra!.callType == "video" ? true : false); try { - AppState().setchatUserDetails = UserAutoLoginModel(response: Response.fromJson(sessionData.extra.loginDetails.toJson()), errorResponses: null); - await cProv.buildHubConnection().whenComplete(() { - cProv.init(); + AppState().setchatUserDetails = UserAutoLoginModel(response: Response.fromJson(sessionData.extra!.loginDetails!.toJson()), errorResponses: null); + await cProv!.buildHubConnection().whenComplete(() { + cProv!.init(); isCallConnected = true; }); } catch (e) { @@ -82,22 +82,22 @@ class _StartCallPageState extends State { } void startIosCall() async { - IosCallPayload iosCallPayload = widget.payload; + IosCallPayload iosCallPayload = widget.payload!; var userID = iosCallPayload.incomingCallReciverId; var callType = iosCallPayload.incomingCallType; SingleUserChatModel inCallData = SingleUserChatModel( targetUserName: iosCallPayload.incomingCallerName, chatEventId: 3, - targetUserId: int.parse(iosCallPayload.incomingCallerId), + targetUserId: int.parse(iosCallPayload.incomingCallerId!), currentUserId: int.parse(userID.toString()), ); - if (cProv.isUserOnline) { + if (cProv!.isUserOnline) { AppState().isBackgroundCall = true; if (kDebugMode) { print("====== Processing Incoming Call in Online State ========="); } - await cProv.startIncomingCallViaKit(inCallData: inCallData.toJson(), isVCall: callType == "video" ? true : false); - cProv.init(); + await cProv!.startIncomingCallViaKit(inCallData: inCallData.toJson(), isVCall: callType == "video" ? true : false); + cProv!.init(); isCallConnected = true; } else { if (kDebugMode) { @@ -109,11 +109,11 @@ class _StartCallPageState extends State { AppState().setchatUserDetails = userLoginResponse; AppSharedPrefs().setStringFromPrefs("userLoginChatDetails", jsonEncode(userLoginResponse.response)); - await cProv.startIncomingCallViaKit(inCallData: inCallData.toJson(), isVCall: callType == "video" ? true : false); + await cProv!.startIncomingCallViaKit(inCallData: inCallData.toJson(), isVCall: callType == "video" ? true : false); try { AppState().setchatUserDetails = UserAutoLoginModel(response: userLoginResponse.response, errorResponses: null); - await cProv.buildHubConnection().whenComplete(() { - cProv.init(); + await cProv!.buildHubConnection().whenComplete(() { + cProv!.init(); isCallConnected = true; }); } catch (e) { @@ -126,11 +126,11 @@ class _StartCallPageState extends State { @override Widget build(BuildContext context) { cProv = context.read(); - if (!cProv.isOutGoingCall) { + if (!cProv!.isOutGoingCall) { if (Platform.isAndroid) { startCall(); } else if (Platform.isIOS) { - cProv.buildHubConnection(); + cProv!.buildHubConnection(); startIosCall(); } } @@ -138,7 +138,7 @@ class _StartCallPageState extends State { return Scaffold( extendBody: true, body: Consumer( - builder: (BuildContext context, ChatCallProvider prov, Widget child) { + builder: (BuildContext context, ChatCallProvider prov, Widget? child) { return prov.isIncomingCallLoader ? const SizedBox( width: double.infinity, @@ -155,7 +155,7 @@ class _StartCallPageState extends State { children: [ if (!prov.isAudioCall && prov.isVideoCall) RTCVideoView( - prov.remoteRenderer, + prov.remoteRenderer!, objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitContain, key: const Key('remote'), ), @@ -174,7 +174,7 @@ class _StartCallPageState extends State { height: 200, width: 140, child: RTCVideoView( - prov.localVideoRenderer, + prov.localVideoRenderer!, mirror: true, // filterQuality: FilterQuality.high, objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover, @@ -225,7 +225,7 @@ class _StartCallPageState extends State { height: 10, ), Text( - prov.incomingCallData.targetUserName ?? "", + prov.incomingCallData!.targetUserName ?? "", style: const TextStyle( fontSize: 21, decoration: TextDecoration.none, @@ -384,7 +384,7 @@ class _StartCallPageState extends State { children: [ if (!prov.isAudioCall && prov.isVideoCall) RTCVideoView( - prov.remoteRenderer, + prov.remoteRenderer!, objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitContain, key: const Key('remote'), ), @@ -403,7 +403,7 @@ class _StartCallPageState extends State { height: 200, width: 140, child: RTCVideoView( - prov.localVideoRenderer, + prov.localVideoRenderer!, mirror: true, objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover, ), @@ -453,7 +453,7 @@ class _StartCallPageState extends State { height: 10, ), Text( - prov.outGoingCallData.receiverName, + prov.outGoingCallData!.receiverName!, style: const TextStyle( fontSize: 21, decoration: TextDecoration.none, diff --git a/lib/voipcall/call/chat_outgoing_call_screen.dart b/lib/voipcall/call/chat_outgoing_call_screen.dart index f3d6b950..adcd0d2a 100644 --- a/lib/voipcall/call/chat_outgoing_call_screen.dart +++ b/lib/voipcall/call/chat_outgoing_call_screen.dart @@ -1,7 +1,7 @@ import 'dart:ui'; -import 'package:diplomaticquarterapp/models/chat/call.dart'; import 'package:diplomaticquarterapp/voipcall/consts.dart'; +import 'package:diplomaticquarterapp/voipcall/model/call.dart'; import 'package:diplomaticquarterapp/voipcall/provider/chat_call_provider.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -9,17 +9,17 @@ import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:provider/provider.dart'; class OutGoingCall extends StatefulWidget { - CallDataModel outGoingCallData; + CallDataModel? outGoingCallData; bool isVideoCall; - OutGoingCall({Key key, this.outGoingCallData, this.isVideoCall}) : super(key: key); + OutGoingCall({Key? key, this.outGoingCallData, this.isVideoCall = false}) : super(key: key); @override _OutGoingCallState createState() => _OutGoingCallState(); } class _OutGoingCallState extends State { - ChatCallProvider callProvider; + ChatCallProvider? callProvider; //late ChatProviderModel chatProvider; bool loader = true; @@ -29,8 +29,8 @@ class _OutGoingCallState extends State { } Future init() async { - widget.isVideoCall ? callProvider.isVideoCall = true : callProvider.isVideoCall = false; - callProvider.isOutGoingCall = true; + widget.isVideoCall ? callProvider!.isVideoCall = true : callProvider!.isVideoCall = false; + callProvider!.isOutGoingCall = true; // IosCallPayload payload = IosCallPayload( // incomingCallerId: widget.outGoingCallData.callerId.toString(), // incomingCallerName: widget.outGoingCallData.callerName, @@ -39,7 +39,7 @@ class _OutGoingCallState extends State { // uuid: "", // callData: widget.outGoingCallData.toRawJson()); // await Utils.saveStringFromPrefs("iosCallPayload", jsonEncode(payload)); - await callProvider.initLocalCamera(callData: widget.outGoingCallData, context: context); + await callProvider!.initLocalCamera(callData: widget.outGoingCallData, context: context); loader = false; } @@ -53,7 +53,7 @@ class _OutGoingCallState extends State { callProvider = Provider.of(context, listen: false); init(); return Scaffold( - body: Consumer(builder: (BuildContext context, ChatCallProvider chatcp, Widget child) { + body: Consumer(builder: (BuildContext context, ChatCallProvider chatcp, Widget? child) { return loader ? const Center( child: CircularProgressIndicator(), @@ -64,7 +64,7 @@ class _OutGoingCallState extends State { if (chatcp.isVideoCall) Positioned.fill( child: RTCVideoView( - chatcp.localVideoRenderer, + chatcp.localVideoRenderer!, objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover, ), ), @@ -111,7 +111,7 @@ class _OutGoingCallState extends State { height: 10, ), Text( - widget.outGoingCallData.receiverName.toString().replaceAll(".", " "), + widget.outGoingCallData!.receiverName.toString().replaceAll(".", " "), style: const TextStyle( fontSize: 21, fontWeight: FontWeight.bold, @@ -187,7 +187,7 @@ class _OutGoingCallState extends State { ); } - BoxDecoration cardRadius(double radius, {Color color, double elevation}) { + BoxDecoration cardRadius(double radius, {Color? color, double? elevation}) { return BoxDecoration( shape: BoxShape.rectangle, color: color ?? Colors.white, diff --git a/lib/voipcall/model/call.dart b/lib/voipcall/model/call.dart index 1efaebb3..4848b4a3 100644 --- a/lib/voipcall/model/call.dart +++ b/lib/voipcall/model/call.dart @@ -20,18 +20,18 @@ class CallDataModel { this.callType, }); - int callerId; - String callerName; - String callerEmail; - String callerTitle; - dynamic callerPhone; - int receiverId; - String receiverName; - String receiverEmail; - dynamic receiverTitle; - dynamic receiverPhone; - String title; - String callType; + int? callerId; + String? callerName; + String? callerEmail; + String? callerTitle; + dynamic? callerPhone; + int? receiverId; + String? receiverName; + String? receiverEmail; + dynamic? receiverTitle; + dynamic? receiverPhone; + String? title; + String? callType; factory CallDataModel.fromRawJson(String str) => CallDataModel.fromJson(json.decode(str)); @@ -79,9 +79,9 @@ class CallSessionPayLoad { this.sdp, }); - int target; - int caller; - Sdp sdp; + int? target; + int? caller; + Sdp? sdp; factory CallSessionPayLoad.fromRawJson(String str) => CallSessionPayLoad.fromJson(json.decode(str)); @@ -106,8 +106,8 @@ class Sdp { this.sdp, }); - String type; - String sdp; + String? type; + String? sdp; factory Sdp.fromRawJson(String str) => Sdp.fromJson(json.decode(str)); @@ -127,12 +127,12 @@ class Sdp { // final iosCallPayload = iosCallPayloadFromJson(jsonString); class IosCallPayload { - String incomingCallType; - String incomingCallerId; - String incomingCallReciverId; - String incomingCallerName; - String callData; - String uuid; + String? incomingCallType; + String? incomingCallerId; + String? incomingCallReciverId; + String? incomingCallerName; + String? callData; + String? uuid; IosCallPayload({ this.incomingCallType, diff --git a/lib/voipcall/model/get_single_user_chat_call.dart b/lib/voipcall/model/get_single_user_chat_call.dart index f150a27b..939743d0 100644 --- a/lib/voipcall/model/get_single_user_chat_call.dart +++ b/lib/voipcall/model/get_single_user_chat_call.dart @@ -38,32 +38,32 @@ class SingleUserChatModel { this.voice, this.voiceController}); - int userChatHistoryId; - int userChatHistoryLineId; - String contant; - String contantNo; - int currentUserId; - String currentUserName; - String currentUserEmail; - int targetUserId; - String targetUserName; - String targetUserEmail; - String encryptedTargetUserId; - String encryptedTargetUserName; - int chatEventId; + int? userChatHistoryId; + int? userChatHistoryLineId; + String? contant; + String? contantNo; + int? currentUserId; + String? currentUserName; + String? currentUserEmail; + int? targetUserId; + String? targetUserName; + String? targetUserEmail; + String? encryptedTargetUserId; + String? encryptedTargetUserName; + int? chatEventId; dynamic fileTypeId; - bool isSeen; - bool isDelivered; - DateTime createdDate; - int chatSource; - String conversationId; - FileTypeResponse fileTypeResponse; - UserChatReplyResponse userChatReplyResponse; - bool isReplied; - bool isImageLoaded; - Uint8List image; - File voice; - AudioPlayer voiceController; + bool? isSeen; + bool? isDelivered; + DateTime? createdDate; + int? chatSource; + String? conversationId; + FileTypeResponse? fileTypeResponse; + UserChatReplyResponse? userChatReplyResponse; + bool? isReplied; + bool? isImageLoaded; + Uint8List? image; + File? voice; + AudioPlayer? voiceController; factory SingleUserChatModel.fromJson(Map json) => SingleUserChatModel( userChatHistoryId: json["userChatHistoryId"] == null ? null : json["userChatHistoryId"], @@ -110,11 +110,11 @@ class SingleUserChatModel { "fileTypeId": fileTypeId, "isSeen": isSeen == null ? null : isSeen, "isDelivered": isDelivered == null ? null : isDelivered, - "createdDate": createdDate == null ? null : createdDate.toIso8601String(), + "createdDate": createdDate == null ? null : createdDate!.toIso8601String(), "chatSource": chatSource == null ? null : chatSource, "conversationId": conversationId == null ? null : conversationId, - "fileTypeResponse": fileTypeResponse == null ? null : fileTypeResponse.toJson(), - "userChatReplyResponse": userChatReplyResponse == null ? null : userChatReplyResponse.toJson(), + "fileTypeResponse": fileTypeResponse == null ? null : fileTypeResponse!.toJson(), + "userChatReplyResponse": userChatReplyResponse == null ? null : userChatReplyResponse!.toJson(), }; } @@ -127,7 +127,7 @@ class FileTypeResponse { this.fileName, }); - int fileTypeId; + int? fileTypeId; dynamic fileTypeName; dynamic fileTypeDescription; dynamic fileKind; @@ -165,18 +165,18 @@ class UserChatReplyResponse { this.image, this.voice}); - int userChatHistoryId; - int chatEventId; - String contant; - String contantNo; + int? userChatHistoryId; + int? chatEventId; + String? contant; + String? contantNo; dynamic fileTypeId; - DateTime createdDate; - int targetUserId; - String targetUserName; - FileTypeResponse fileTypeResponse; - bool isImageLoaded; - Uint8List image; - Uint8List voice; + DateTime? createdDate; + int? targetUserId; + String? targetUserName; + FileTypeResponse? fileTypeResponse; + bool? isImageLoaded; + Uint8List? image; + Uint8List? voice; factory UserChatReplyResponse.fromJson(Map json) => UserChatReplyResponse( userChatHistoryId: json["userChatHistoryId"] == null ? null : json["userChatHistoryId"], @@ -199,9 +199,9 @@ class UserChatReplyResponse { "contant": contant == null ? null : contant, "contantNo": contantNo == null ? null : contantNo, "fileTypeId": fileTypeId, - "createdDate": createdDate == null ? null : createdDate.toIso8601String(), + "createdDate": createdDate == null ? null : createdDate!.toIso8601String(), "targetUserId": targetUserId == null ? null : targetUserId, "targetUserName": targetUserName == null ? null : targetUserName, - "fileTypeResponse": fileTypeResponse == null ? null : fileTypeResponse.toJson(), + "fileTypeResponse": fileTypeResponse == null ? null : fileTypeResponse!.toJson(), }; } diff --git a/lib/voipcall/model/get_user_login_token.dart b/lib/voipcall/model/get_user_login_token.dart index 10853e8b..8d55461f 100644 --- a/lib/voipcall/model/get_user_login_token.dart +++ b/lib/voipcall/model/get_user_login_token.dart @@ -10,8 +10,8 @@ class UserAutoLoginModel { this.errorResponses, }); - Response response; - List errorResponses; + Response? response; + List? errorResponses; factory UserAutoLoginModel.fromJson(Map json) => UserAutoLoginModel( response: json["response"] == null ? null : Response.fromJson(json["response"]), @@ -19,8 +19,8 @@ class UserAutoLoginModel { ); Map toJson() => { - "response": response == null ? null : response.toJson(), - "errorResponses": errorResponses == null ? null : List.from(errorResponses.map((x) => x.toJson())), + "response": response == null ? null : response!.toJson(), + "errorResponses": errorResponses == null ? null : List.from(errorResponses!.map((x) => x.toJson())), }; } @@ -38,16 +38,16 @@ class Response { this.encryptedUserName, }); - int id; - String userName; - String email; - String phone; - String title; - String token; - bool isDomainUser; - bool isActiveCode; - String encryptedUserId; - String encryptedUserName; + int? id; + String? userName; + String? email; + String? phone; + String? title; + String? token; + bool? isDomainUser; + bool? isActiveCode; + String? encryptedUserId; + String? encryptedUserName; factory Response.fromJson(Map json) => Response( id: json["id"] == null ? null : json["id"], @@ -82,8 +82,8 @@ class ErrorResponse { this.message, }); - String fieldName; - String message; + String? fieldName; + String? message; factory ErrorResponse.fromJson(Map json) => ErrorResponse( fieldName: json["fieldName"] == null ? null : json["fieldName"], diff --git a/lib/voipcall/model/incoming_call_model.dart b/lib/voipcall/model/incoming_call_model.dart index a36c11b3..94945052 100644 --- a/lib/voipcall/model/incoming_call_model.dart +++ b/lib/voipcall/model/incoming_call_model.dart @@ -5,32 +5,32 @@ import 'dart:convert'; class IncomingCallModel { - String actionColor; - String appName; - Args args; - String avatar; - String backgroundColor; - String backgroundUrl; - int duration; - Extra extra; - String from; - String handle; - Args headers; - String id; - bool isAccepted; - bool isCustomNotification; - bool isCustomSmallExNotification; - bool isShowCallback; - bool isShowLogo; - bool isShowMissedCallNotification; - String nameCaller; - String ringtonePath; - String textAccept; - String textCallback; - String textDecline; - String textMissedCall; - int type; - String uuid; + String? actionColor; + String? appName; + Args? args; + String? avatar; + String? backgroundColor; + String? backgroundUrl; + int? duration; + Extra? extra; + String? from; + String? handle; + Args? headers; + String? id; + bool? isAccepted; + bool? isCustomNotification; + bool? isCustomSmallExNotification; + bool? isShowCallback; + bool? isShowLogo; + bool? isShowMissedCallNotification; + String? nameCaller; + String? ringtonePath; + String? textAccept; + String? textCallback; + String? textDecline; + String? textMissedCall; + int? type; + String? uuid; IncomingCallModel({ this.actionColor, @@ -137,10 +137,10 @@ class Args { } class Extra { - LoginDetails loginDetails; - bool isIncomingCall; - CallerDetails callerDetails; - String callType; + LoginDetails? loginDetails; + bool? isIncomingCall; + CallerDetails? callerDetails; + String? callType; Extra({ this.loginDetails, @@ -169,25 +169,25 @@ class Extra { } class CallerDetails { - int userChatHistoryId; - String contant; - FileTypeResponse fileTypeResponse; - String currentUserName; - String targetUserEmail; - String conversationId; - String encryptedTargetUserId; - int targetUserId; - bool isSeen; - int userChatHistoryLineId; - bool isDelivered; - String targetUserName; - int currentUserId; - DateTime createdDate; - String currentUserEmail; - String contantNo; - int chatEventId; - String encryptedTargetUserName; - int chatSource; + int? userChatHistoryId; + String? contant; + FileTypeResponse? fileTypeResponse; + String? currentUserName; + String? targetUserEmail; + String? conversationId; + String? encryptedTargetUserId; + int? targetUserId; + bool? isSeen; + int? userChatHistoryLineId; + bool? isDelivered; + String? targetUserName; + int? currentUserId; + DateTime? createdDate; + String? currentUserEmail; + String? contantNo; + int? chatEventId; + String? encryptedTargetUserName; + int? chatSource; CallerDetails({ this.userChatHistoryId, @@ -261,7 +261,7 @@ class CallerDetails { } class FileTypeResponse { - int fileTypeId; + int? fileTypeId; FileTypeResponse({ this.fileTypeId, @@ -281,15 +281,15 @@ class FileTypeResponse { } class LoginDetails { - bool isActiveCode; - int id; - String encryptedUserName; - String userName; - String title; - String encryptedUserId; - String email; - bool isDomainUser; - String token; + bool? isActiveCode; + int? id; + String? encryptedUserName; + String? userName; + String? title; + String? encryptedUserId; + String? email; + bool? isDomainUser; + String? token; LoginDetails({ this.isActiveCode, diff --git a/lib/voipcall/model/webrtc_payloads.dart b/lib/voipcall/model/webrtc_payloads.dart index 768155d2..b4019419 100644 --- a/lib/voipcall/model/webrtc_payloads.dart +++ b/lib/voipcall/model/webrtc_payloads.dart @@ -10,8 +10,8 @@ class RemoteIceCandidatePayLoad { this.candidate, }); - int target; - Candidate candidate; + int? target; + Candidate? candidate; factory RemoteIceCandidatePayLoad.fromRawJson(String str) => RemoteIceCandidatePayLoad.fromJson(json.decode(str)); @@ -36,10 +36,10 @@ class Candidate { this.usernameFragment, }); - String candidate; - String sdpMid; - int sdpMLineIndex; - String usernameFragment; + String? candidate; + String? sdpMid; + int? sdpMLineIndex; + String? usernameFragment; factory Candidate.fromRawJson(String str) => Candidate.fromJson(json.decode(str)); diff --git a/lib/voipcall/provider/chat_call_provider.dart b/lib/voipcall/provider/chat_call_provider.dart index 4a1e1c4a..c66f4bb1 100644 --- a/lib/voipcall/provider/chat_call_provider.dart +++ b/lib/voipcall/provider/chat_call_provider.dart @@ -9,8 +9,10 @@ import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/voipcall/call/chat_incoming_call_screen.dart'; import 'package:diplomaticquarterapp/voipcall/consts.dart'; +import 'package:diplomaticquarterapp/voipcall/model/call.dart'; import 'package:diplomaticquarterapp/voipcall/model/get_single_user_chat_call.dart'; import 'package:diplomaticquarterapp/voipcall/model/get_user_login_token.dart'; +import 'package:diplomaticquarterapp/voipcall/model/webrtc_payloads.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart'; @@ -90,7 +92,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { HubConnection hub; HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true); hub = HubConnectionBuilder() - .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails.response.id}&source=Desktop&access_token=${AppState().chatDetails.response.token}", options: httpOp) + .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Desktop&access_token=${AppState().chatDetails!.response!.token}", options: httpOp) .withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000]).build(); return hub; } @@ -99,11 +101,11 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { if (kDebugMode) { print("=================== Call Listeners Registered ======================="); } - chatHubConnection!.on("OnCallAcceptedAsync", onCallAcceptedAsync!); - chatHubConnection!.on("OnIceCandidateAsync", onIceCandidateAsync!); - chatHubConnection!.on("OnOfferAsync", onOfferAsync!); - chatHubConnection!.on("OnAnswerOffer", onAnswerOffer!); - chatHubConnection!.on("OnHangUpAsync", onHangUpAsync!); + chatHubConnection!.on("OnCallAcceptedAsync", onCallAcceptedAsync); + chatHubConnection!.on("OnIceCandidateAsync", onIceCandidateAsync); + chatHubConnection!.on("OnOfferAsync", onOfferAsync); + chatHubConnection!.on("OnAnswerOffer", onAnswerOffer); + chatHubConnection!.on("OnHangUpAsync", onHangUpAsync); // chatHubConnection!.on("OnCallDeclinedAsync", onCallDeclinedAsync); // chatHubConnection!.on("OnIncomingCallAsync", OnIncomingCallAsync); } @@ -126,12 +128,11 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { ///////////////////////////////////////////////OutGoing Call//////////////////////////////////////////////////// - Future initLocalCamera({callData, BuildContext context, bool isIncomingCall = false}) async { + Future initLocalCamera({callData, BuildContext? context, bool isIncomingCall = false}) async { isCallEnded = false; outGoingCallData = callData; await initStreams(); - - await startCall(callType: isVideoCall ? "Video" : "Audio", context: context); + await startCall(callType: isVideoCall ? "Video" : "Audio"); _pc = await creatOfferWithCon(); connectOutgoing(); notifyListeners(); @@ -142,7 +143,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { // notifyListeners(); } - Future startCall({String callType, BuildContext context}) async { + Future startCall({String? callType}) async { // chatProvModel.isTextMsg = true; // chatProvModel.isAttachmentMsg = false; // chatProvModel.isVoiceMsg = false; @@ -158,10 +159,10 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { // ); await invoke( invokeMethod: "CallUserAsync", - currentUserID: outGoingCallData.callerId, - targetUserID: outGoingCallData.receiverId, + currentUserID: outGoingCallData!.callerId!, + targetUserID: outGoingCallData!.receiverId!, ); - await invoke(invokeMethod: "UpdateUserStatusAsync", currentUserID: outGoingCallData.callerId, targetUserID: outGoingCallData.receiverId, userStatus: 4); + await invoke(invokeMethod: "UpdateUserStatusAsync", currentUserID: outGoingCallData!.callerId!, targetUserID: outGoingCallData!.receiverId!, userStatus: 4); } // OutGoing Listeners @@ -169,8 +170,8 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { dynamic items = params!.toList(); RTCSessionDescription description = await _createOffer(); await _pc!.setLocalDescription(description); - dynamic payload = {"target": items[0]["id"], "caller": outGoingCallData.callerId, "sdp": description.toMap()}; - invoke(invokeMethod: "OfferAsync", currentUserID: outGoingCallData.callerId, targetUserID: items[0]["id"], data: jsonEncode(payload)); + dynamic payload = {"target": items[0]["id"], "caller": outGoingCallData!.callerId, "sdp": description.toMap()}; + invoke(invokeMethod: "OfferAsync", currentUserID: outGoingCallData!.callerId!, targetUserID: items[0]["id"], data: jsonEncode(payload)); } Future onIceCandidateAsync(List? params) async { @@ -178,7 +179,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { if (isIncomingCall) { RemoteIceCandidatePayLoad data = RemoteIceCandidatePayLoad.fromJson(jsonDecode(items.first.toString())); if (_pc != null) { - await _pc.addCandidate(RTCIceCandidate(data.candidate.candidate, data.candidate.sdpMid, data.candidate.sdpMLineIndex)); + await _pc!.addCandidate(RTCIceCandidate(data.candidate!.candidate, data.candidate!.sdpMid, data.candidate!.sdpMLineIndex)); } } else { if (kDebugMode) { @@ -186,7 +187,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { } RemoteIceCandidatePayLoad data = RemoteIceCandidatePayLoad.fromJson(jsonDecode(items.first.toString())); if (_pc != null) { - await _pc.addCandidate(RTCIceCandidate(data.candidate.candidate, data.candidate.sdpMid, data.candidate.sdpMLineIndex)); + await _pc!.addCandidate(RTCIceCandidate(data.candidate!.candidate, data.candidate!.sdpMid, data.candidate!.sdpMLineIndex)); if (!isCallStarted) { isCallStarted = true; notifyListeners(); @@ -196,14 +197,14 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { if (Platform.isIOS) { Future.delayed(Duration(seconds: 2), () { Navigator.pushReplacement( - providerContext, + providerContext!, MaterialPageRoute( builder: (BuildContext context) => StartCallPage(), )); }); } else { Navigator.pushReplacement( - providerContext, + providerContext!, MaterialPageRoute( builder: (BuildContext context) => StartCallPage(), )); @@ -222,8 +223,8 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { _pc!.setRemoteDescription(RTCSessionDescription(data[0]["sdp"]["sdp"], data[0]["sdp"]["type"])); RTCSessionDescription description = await _createAnswer(); await _pc!.setLocalDescription(description); - dynamic payload = {"target": data[0]["caller"], "caller": AppState().chatDetails.response.id, "sdp": description.toMap()}; - invoke(invokeMethod: "AnswerOfferAsync", currentUserID: AppState().chatDetails.response.id, targetUserID: incomingCallData.targetUserId, data: jsonEncode(payload)); + dynamic payload = {"target": data[0]["caller"], "caller": AppState().chatDetails!.response!.id!, "sdp": description.toMap()}; + invoke(invokeMethod: "AnswerOfferAsync", currentUserID: AppState().chatDetails!.response!.id!, targetUserID: incomingCallData!.targetUserId!, data: jsonEncode(payload)); } // else { // RTCSessionDescription description = await _createAnswer(); @@ -240,8 +241,8 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { if (isIncomingCall) { print("-----------------------Endeddddd By Me---------------------------"); if (chatHubConnection!.state == HubConnectionState.Connected) { - await invoke(invokeMethod: "HangUpAsync", currentUserID: AppState().chatDetails.response.id, targetUserID: incomingCallData.targetUserId, userStatus: 0); - await invoke(invokeMethod: "UpdateUserStatusAsync", currentUserID: AppState().chatDetails.response.id, targetUserID: incomingCallData.targetUserId, userStatus: 1); + await invoke(invokeMethod: "HangUpAsync", currentUserID: AppState().chatDetails!.response!.id!, targetUserID: incomingCallData!.targetUserId!, userStatus: 0); + await invoke(invokeMethod: "UpdateUserStatusAsync", currentUserID: AppState().chatDetails!.response!.id!, targetUserID: incomingCallData!.targetUserId!, userStatus: 1); } isCallStarted = false; isVideoCall = false; @@ -253,38 +254,38 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { isAudioCall = false; if (isCallConnected) { - if (_pc.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) { + if (_pc!.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) { if (kDebugMode) { print("------------------ PC Stopped ----------------------------"); } - _pc.close(); - _pc.dispose(); + _pc!.close(); + _pc!.dispose(); } } if (remoteRenderer != null) { - remoteRenderer.dispose(); + remoteRenderer!.dispose(); remoteRenderer = null; } if (localVideoRenderer != null) { - localVideoRenderer.dispose(); + localVideoRenderer!.dispose(); localVideoRenderer = null; } if (_localStream != null) { - _localStream.dispose(); + _localStream!.dispose(); _localStream = null; } - if (chatHubConnection != null && !isUserOnline) { - chatHubConnection.stop(); + if (chatHubConnection != null && !isUserOnline!) { + chatHubConnection!.stop(); } await FlutterCallkitIncoming.endAllCalls(); return true; } else { if (isOutGoingCall) { - await invoke(invokeMethod: "HangUpAsync", currentUserID: outGoingCallData.callerId, targetUserID: outGoingCallData.receiverId, userStatus: 1); - await invoke(invokeMethod: "UpdateUserStatusAsync", currentUserID: outGoingCallData.callerId, targetUserID: outGoingCallData.receiverId, userStatus: 1); + await invoke(invokeMethod: "HangUpAsync", currentUserID: outGoingCallData!.callerId!, targetUserID: outGoingCallData!.receiverId!, userStatus: 1); + await invoke(invokeMethod: "UpdateUserStatusAsync", currentUserID: outGoingCallData!.callerId!, targetUserID: outGoingCallData!.receiverId!, userStatus: 1); } else if (isIncomingCall) { - await invoke(invokeMethod: "UpdateUserStatusAsync", currentUserID: AppState().chatDetails.response.id, targetUserID: incomingCallData.targetUserId, userStatus: 1); + await invoke(invokeMethod: "UpdateUserStatusAsync", currentUserID: AppState().chatDetails!.response!.id!, targetUserID: incomingCallData!.targetUserId!, userStatus: 1); } isCallStarted = false; isVideoCall = false; @@ -292,22 +293,22 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { isMicOff = false; isLoudSpeaker = false; if (isCallConnected) { - if (_pc.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) { - _pc.close(); - _pc.dispose(); + if (_pc!.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) { + _pc!.close(); + _pc!.dispose(); } } if (remoteRenderer != null) { - remoteRenderer.dispose(); + remoteRenderer!.dispose(); remoteRenderer = null; } if (localVideoRenderer != null) { - localVideoRenderer.dispose(); + localVideoRenderer!.dispose(); localVideoRenderer = null; } if (_localStream != null) { - _localStream.dispose(); + _localStream!.dispose(); _localStream = null; } isOutGoingCall = false; @@ -319,29 +320,29 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { // Incoming Listeners - void onAnswerOffer(List payload) async { + void onAnswerOffer(List? payload) async { // if (isIncomingCall) { // // print("--------------------- On Answer Offer Async ---------------------------------------"); // //await invoke(invokeMethod: "InvokeMobile", currentUserID: AppState().getchatUserDetails!.response!.id!, targetUserID: incomingCallData.targetUserId!, debugData: {"On Answer Offer Async"}); // } else { - var items = payload.toList(); + var items = payload!.toList(); if (kDebugMode) { print("res: " + items.toString()); } CallSessionPayLoad data = CallSessionPayLoad.fromJson(jsonDecode(items.first.toString())); - RTCSessionDescription description = RTCSessionDescription(data.sdp.sdp, 'answer'); - _pc.setRemoteDescription(description); + RTCSessionDescription description = RTCSessionDescription(data.sdp!.sdp, 'answer'); + _pc!.setRemoteDescription(description); // } } - void onHangUpAsync(List params) { + void onHangUpAsync(List? params) { print("--------------------- onHangUp ASYNC ---------------------------------"); - dynamic items = params.toList(); + dynamic items = params!.toList(); // if (kDebugMode) { // logger.i("res: " + items.toString()); // } - if (items[0]["id"] != AppState().chatDetails.response.id) { + if (items[0]["id"] != AppState().chatDetails!.response!.id!) { if (kDebugMode) { print("Call Ended By Other User"); } @@ -350,12 +351,12 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { if (isCallConnected && isUserOnline) { isCallConnected = false; if (!AppState().isLogged) { - Navigator.of(locator().navigatorKey.currentContext).pop(); + Navigator.of(locator().navigatorKey.currentContext!).pop(); } else { - Navigator.of(locator().navigatorKey.currentContext).popUntil(ModalRoute.withName(HOME)); + Navigator.of(locator().navigatorKey.currentContext!).popUntil(ModalRoute.withName(HOME)); } } else { - Navigator.of(locator().navigatorKey.currentContext).pop(); + Navigator.of(locator().navigatorKey.currentContext!).pop(); } }); } else { @@ -363,9 +364,9 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { endCall(isUserOnline: isUserOnline).then((bool value) { if (isCallConnected && isUserOnline) { isCallConnected = false; - Navigator.of(locator().navigatorKey.currentContext).popUntil(ModalRoute.withName(HOME)); + Navigator.of(locator().navigatorKey.currentContext!).popUntil(ModalRoute.withName(HOME)); } else { - Navigator.of(locator().navigatorKey.currentContext).pop(); + Navigator.of(locator().navigatorKey.currentContext!).pop(); } }); } @@ -377,9 +378,9 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { if (isOutGoingCall) { if (isCallConnected && isUserOnline) { isCallConnected = false; - Navigator.of(locator().navigatorKey.currentContext).popUntil(ModalRoute.withName(HOME)); + Navigator.of(locator().navigatorKey.currentContext!).popUntil(ModalRoute.withName(HOME)); } else { - Navigator.of(locator().navigatorKey.currentContext).pop(); + Navigator.of(locator().navigatorKey.currentContext!).pop(); } } } @@ -388,7 +389,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { // Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.chatDetailed)); // isCallConnected = false; // } - // if (items[0]["id"] != AppState().chatDetails!.response!.id && !AppState().isBackgroundCall) { + // if (items[0]["id"] != AppState().chatDetails!!.response!.id && !AppState().isBackgroundCall) { // if (kDebugMode) { // print("Popped Due to Another User"); // } @@ -418,12 +419,12 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { // // "callerEmail": items[0]["email"], // // "callerTitle": items[0]["title"], // // "callerPhone": null, - // // "receiverID": AppState().chatDetails!.response!.id, - // // "receiverName": AppState().chatDetails!.response!.userName, - // // "receiverEmail": AppState().chatDetails!.response!.email, - // // "receiverTitle": AppState().chatDetails!.response!.title, - // // "receiverPhone": AppState().chatDetails!.response!.phone, - // // "title": AppState().chatDetails!.response!.userName!.replaceAll(".", " "), + // // "receiverID": AppState().chatDetails!!.response!.id, + // // "receiverName": AppState().chatDetails!!.response!.userName, + // // "receiverEmail": AppState().chatDetails!!.response!.email, + // // "receiverTitle": AppState().chatDetails!!.response!.title, + // // "receiverPhone": AppState().chatDetails!!.response!.phone, + // // "title": AppState().chatDetails!!.response!.userName!.replaceAll(".", " "), // // "callType": items[1] ? "Video" : "Audio", // // }; // // CallDataModel callData = CallDataModel.fromJson(json); @@ -436,12 +437,12 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { // // "callerEmail": items[0]["email"], // // "callerTitle": items[0]["title"], // // "callerPhone": null, - // // "receiverID": AppState().chatDetails!.response!.id, - // // "receiverName": AppState().chatDetails!.response!.userName, - // // "receiverEmail": AppState().chatDetails!.response!.email, - // // "receiverTitle": AppState().chatDetails!.response!.title, - // // "receiverPhone": AppState().chatDetails!.response!.phone, - // // "title": AppState().chatDetails!.response!.userName!.replaceAll(".", " "), + // // "receiverID": AppState().chatDetails!!.response!.id, + // // "receiverName": AppState().chatDetails!!.response!.userName, + // // "receiverEmail": AppState().chatDetails!!.response!.email, + // // "receiverTitle": AppState().chatDetails!!.response!.title, + // // "receiverPhone": AppState().chatDetails!!.response!.phone, + // // "title": AppState().chatDetails!!.response!.userName!.replaceAll(".", " "), // // "callType": items[1] ? "Video" : "Audio", // // }; // // CallDataModel callData = CallDataModel.fromJson(json); @@ -480,7 +481,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { //// Invoke Methods - Future invoke({String invokeMethod, int currentUserID, int targetUserID, var data, int userStatus = 1, var debugData}) async { + Future invoke({required String invokeMethod, required int currentUserID, required int targetUserID, var data, int userStatus = 1, var debugData}) async { List args = []; if (invokeMethod == "CallUserAsync") { args = [currentUserID, targetUserID, isVideoCall]; @@ -501,17 +502,17 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { args = [debugData]; } try { - await chatHubConnection.invoke("$invokeMethod", args: args); + await chatHubConnection!.invoke("$invokeMethod", args: args); } catch (e) { print(e); } } void stopListeners() async { - chatHubConnection.off('OnCallDeclinedAsync'); - chatHubConnection.off('OnCallAcceptedAsync'); - chatHubConnection.off('OnIceCandidateAsync'); - chatHubConnection.off('OnAnswerOffer'); + chatHubConnection!.off('OnCallDeclinedAsync'); + chatHubConnection!.off('OnCallAcceptedAsync'); + chatHubConnection!.off('OnIceCandidateAsync'); + chatHubConnection!.off('OnAnswerOffer'); } void playRingtone() async { @@ -559,24 +560,24 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { // await pc.addStream(_localStream!); //Changed By Aamir _localStream?.getTracks().forEach((track) { - pc.addTrack(track, _localStream); + pc.addTrack(track, _localStream!); }); pc.onConnectionState = (RTCPeerConnectionState state) {}; pc.onAddStream = (MediaStream stream) { - remoteRenderer.srcObject = stream; + remoteRenderer!.srcObject = stream; notifyListeners(); }; pc.onIceCandidate = (RTCIceCandidate e) async { if (isIncomingCall) { if (e.candidate != null) { - var payload = {"target": incomingCallData.targetUserId, "candidate": e.toMap()}; - invoke(invokeMethod: "IceCandidateAsync", currentUserID: AppState().chatDetails.response.id, targetUserID: incomingCallData.targetUserId, data: jsonEncode(payload)); + var payload = {"target": incomingCallData!.targetUserId, "candidate": e.toMap()}; + invoke(invokeMethod: "IceCandidateAsync", currentUserID: AppState().chatDetails!.response!.id!, targetUserID: incomingCallData!.targetUserId!, data: jsonEncode(payload)); notifyListeners(); } } else { if (e.candidate != null) { - var payload = {"target": outGoingCallData.callerId, "candidate": e.toMap()}; - invoke(invokeMethod: "IceCandidateAsync", currentUserID: outGoingCallData.callerId, targetUserID: outGoingCallData.receiverId, data: jsonEncode(payload)); + var payload = {"target": outGoingCallData!.callerId, "candidate": e.toMap()}; + invoke(invokeMethod: "IceCandidateAsync", currentUserID: outGoingCallData!.callerId!, targetUserID: outGoingCallData!.receiverId!, data: jsonEncode(payload)); } } }; @@ -635,13 +636,13 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { // } Future _createOffer() async { - RTCSessionDescription description = await _pc.createOffer(); + RTCSessionDescription description = await _pc!.createOffer(); // _offer = true; return description; } Future _createAnswer() async { - RTCSessionDescription description = await _pc.createAnswer(); + RTCSessionDescription description = await _pc!.createAnswer(); // _offer = false; return description; } @@ -652,7 +653,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { void micOff() { isMicOff = !isMicOff; - _localStream.getAudioTracks().forEach((track) { + _localStream!.getAudioTracks().forEach((track) { track.enabled = !track.enabled; }); notifyListeners(); @@ -660,7 +661,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { void camOff() { isCamOff = !isCamOff; - _localStream.getVideoTracks().forEach((track) { + _localStream!.getVideoTracks().forEach((track) { track.enabled = !track.enabled; }); // if (isCamOff) { @@ -673,7 +674,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { void loudOn() { isLoudSpeaker = !isLoudSpeaker; - remoteRenderer.srcObject?.getAudioTracks().forEach((track) { + remoteRenderer!.srcObject?.getAudioTracks().forEach((track) { if (isLoudSpeaker) { track.enableSpeakerphone(true); } else { @@ -685,7 +686,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { void switchCamera() { isFrontCamera = !isFrontCamera; - Helper.switchCamera(_localStream.getVideoTracks()[0]); + Helper.switchCamera(_localStream!.getVideoTracks()[0]); notifyListeners(); } @@ -695,7 +696,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { List devices = await navigator.mediaDevices.enumerateDevices(); remoteRenderer = RTCVideoRenderer(); localVideoRenderer ??= RTCVideoRenderer(); - await localVideoRenderer.initialize(); + await localVideoRenderer!.initialize(); try { _localStream = await navigator.mediaDevices.getUserMedia({ 'audio': true, @@ -714,8 +715,8 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { if (kDebugMode) { print(_localStream..toString()); } - localVideoRenderer.srcObject = _localStream; - localVideoRenderer.value = (const RTCVideoValue(width: 200, height: 200, renderVideo: true)); + localVideoRenderer!.srcObject = _localStream; + localVideoRenderer!.value = (const RTCVideoValue(width: 200, height: 200, renderVideo: true)); print("Working localStream"); } catch (e) { print("Failed to get user media: $e"); @@ -781,7 +782,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { // : audioConstraints); // localVideoRenderer.srcObject = _localStream; - await remoteRenderer.initialize(); + await remoteRenderer!.initialize(); notifyListeners(); } @@ -800,7 +801,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { } void connectIncomingCall() { - invoke(invokeMethod: "answerCallAsync", currentUserID: AppState().getchatUserDetails.response.id, targetUserID: incomingCallData.targetUserId); + invoke(invokeMethod: "answerCallAsync", currentUserID: AppState().getchatUserDetails.response!.id!, targetUserID: incomingCallData!.targetUserId!); isIncomingCallLoader = false; isIncomingCall = true; // isVideoCall = true; @@ -842,7 +843,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { } class ChatService extends BaseService { - Future getUserCallToken({String userid}) async { + Future getUserCallToken({required String userid}) async { UserAutoLoginModel userLoginResponse = UserAutoLoginModel(); baseAppClient.post( "${ApiConsts.chatLoginTokenUrl}externaluserlogin",