|  |  |  | @ -55,9 +55,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> getUserAutoLoginToken() async { | 
		
	
		
			
				|  |  |  |  |     userLoginToken.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken(); | 
		
	
		
			
				|  |  |  |  |     print("======================================= Chat Login Token Check ====================================="); | 
		
	
		
			
				|  |  |  |  |     logger.d(userLoginResponse.toJson()); | 
		
	
		
			
				|  |  |  |  |     print("======================================= Chat Login Token Check ====================================="); | 
		
	
		
			
				|  |  |  |  |     if (userLoginResponse.response != null) { | 
		
	
		
			
				|  |  |  |  |       AppState().setchatUserDetails = userLoginResponse; | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
	
		
			
				
					|  |  |  | @ -677,7 +674,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   String? getFileExtension(String fileName) { | 
		
	
		
			
				|  |  |  |  |     try { | 
		
	
		
			
				|  |  |  |  |       print("Ext: " + "." + fileName.split('.').last); | 
		
	
		
			
				|  |  |  |  |       if (kDebugMode) { | 
		
	
		
			
				|  |  |  |  |         print("ext: " + "." + fileName.split('.').last); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |       return "." + fileName.split('.').last; | 
		
	
		
			
				|  |  |  |  |     } catch (e) { | 
		
	
		
			
				|  |  |  |  |       return null; | 
		
	
	
		
			
				
					|  |  |  | @ -886,8 +885,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
		
			
				|  |  |  |  |       await deleteFile(userID); | 
		
	
		
			
				|  |  |  |  |       Uint8List decodedBytes = base64Decode(encodedBytes); | 
		
	
		
			
				|  |  |  |  |       Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); // 1 | 
		
	
		
			
				|  |  |  |  |       late File imageFile = File("${appDocumentsDirectory.path}/$userID.jpg"); | 
		
	
		
			
				|  |  |  |  |       Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); | 
		
	
		
			
				|  |  |  |  |       String dirPath = '${appDocumentsDirectory.path}/chat_images'; | 
		
	
		
			
				|  |  |  |  |       if (!await Directory(dirPath).exists()) { | 
		
	
		
			
				|  |  |  |  |         await Directory(dirPath).create(); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |       late File imageFile = File("$dirPath/$userID.jpg"); | 
		
	
		
			
				|  |  |  |  |       imageFile.writeAsBytesSync(decodedBytes); | 
		
	
		
			
				|  |  |  |  |       return imageFile; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
	
		
			
				
					|  |  |  | @ -895,7 +898,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future deleteFile(String userID) async { | 
		
	
		
			
				|  |  |  |  |     Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); | 
		
	
		
			
				|  |  |  |  |     late File imageFile = File('${appDocumentsDirectory.path}/$userID.jpg'); | 
		
	
		
			
				|  |  |  |  |     String dirPath = '${appDocumentsDirectory.path}/chat_images'; | 
		
	
		
			
				|  |  |  |  |     late File imageFile = File('$dirPath/$userID.jpg'); | 
		
	
		
			
				|  |  |  |  |     if (await imageFile.exists()) { | 
		
	
		
			
				|  |  |  |  |       await imageFile.delete(); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
	
		
			
				
					|  |  |  | @ -972,7 +976,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> initAudio({required int receiverId}) async { | 
		
	
		
			
				|  |  |  |  |     appDirectory = await getApplicationDocumentsDirectory(); | 
		
	
		
			
				|  |  |  |  |     path = "${appDirectory.path}/${AppState().chatDetails!.response!.id}-$receiverID-${DateTime.now().microsecondsSinceEpoch}.aac"; | 
		
	
		
			
				|  |  |  |  |     String dirPath = '${appDirectory.path}/chat_audios'; | 
		
	
		
			
				|  |  |  |  |     if (!await Directory(dirPath).exists()) { | 
		
	
		
			
				|  |  |  |  |       await Directory(dirPath).create(); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     path = "$dirPath/${AppState().chatDetails!.response!.id}-$receiverID-${DateTime.now().microsecondsSinceEpoch}.aac"; | 
		
	
		
			
				|  |  |  |  |     recorderController = RecorderController() | 
		
	
		
			
				|  |  |  |  |       ..androidEncoder = AndroidEncoder.aac | 
		
	
		
			
				|  |  |  |  |       ..androidOutputFormat = AndroidOutputFormat.mpeg4 | 
		
	
	
		
			
				
					|  |  |  | @ -996,7 +1004,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |       startRecoding(); | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
		
			
				|  |  |  |  |       recorderController.reset(); | 
		
	
		
			
				|  |  |  |  |       logger.d(recorderController.isRecording); | 
		
	
		
			
				|  |  |  |  |       await recorderController.record(path); | 
		
	
		
			
				|  |  |  |  |       logger.d(recorderController.isRecording); | 
		
	
		
			
				|  |  |  |  |       _recodeDuration = 0; | 
		
	
		
			
				|  |  |  |  |       _startTimer(); | 
		
	
		
			
				|  |  |  |  |       isRecoding = !isRecoding; | 
		
	
	
		
			
				
					|  |  |  | @ -1013,27 +1023,16 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void _pauseTimer() { | 
		
	
		
			
				|  |  |  |  |     _timer?.cancel(); | 
		
	
		
			
				|  |  |  |  |     _timer = Timer.periodic(const Duration(seconds: 1), (Timer t) { | 
		
	
		
			
				|  |  |  |  |       _recodeDuration++; | 
		
	
		
			
				|  |  |  |  |       //  buildTimer(); | 
		
	
		
			
				|  |  |  |  |       notifyListeners(); | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> pauseRecoding() async { | 
		
	
		
			
				|  |  |  |  |     isPause = true; | 
		
	
		
			
				|  |  |  |  |     isPlaying = true; | 
		
	
		
			
				|  |  |  |  |     recorderController.pause(); | 
		
	
		
			
				|  |  |  |  |     path = await recorderController.stop(false); | 
		
	
		
			
				|  |  |  |  |     print(path); | 
		
	
		
			
				|  |  |  |  |     File file = File(path!); | 
		
	
		
			
				|  |  |  |  |     file.readAsBytesSync(); | 
		
	
		
			
				|  |  |  |  |     await playerController.preparePlayer(file.path, 1.0); | 
		
	
		
			
				|  |  |  |  |     var tempDuration = _recodeDuration; | 
		
	
		
			
				|  |  |  |  |     _recodeDuration = tempDuration; | 
		
	
		
			
				|  |  |  |  |     _pauseTimer(); | 
		
	
		
			
				|  |  |  |  |     // var tempDuration = _recodeDuration; | 
		
	
		
			
				|  |  |  |  |     // _recodeDuration = tempDuration; | 
		
	
		
			
				|  |  |  |  |     _timer?.cancel(); | 
		
	
		
			
				|  |  |  |  |     notifyListeners(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
	
		
			
				
					|  |  |  | @ -1047,19 +1046,20 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> deleteRecoding() async { | 
		
	
		
			
				|  |  |  |  |     print(path); | 
		
	
		
			
				|  |  |  |  |     _recodeDuration = 0; | 
		
	
		
			
				|  |  |  |  |     _timer?.cancel(); | 
		
	
		
			
				|  |  |  |  |     // path = await recorderController.stop(false); | 
		
	
		
			
				|  |  |  |  |    // path = await recorderController.stop(true); | 
		
	
		
			
				|  |  |  |  |     recorderController.reset(); | 
		
	
		
			
				|  |  |  |  |     print(path); | 
		
	
		
			
				|  |  |  |  |     if (path != null && path!.isNotEmpty) { | 
		
	
		
			
				|  |  |  |  |       File delFile = File(path!); | 
		
	
		
			
				|  |  |  |  |       double fileSizeInKB = delFile.lengthSync() / 1024; | 
		
	
		
			
				|  |  |  |  |       double fileSizeInMB = fileSizeInKB / 1024; | 
		
	
		
			
				|  |  |  |  |       debugPrint("Deleted file size: ${delFile.lengthSync()}"); | 
		
	
		
			
				|  |  |  |  |       debugPrint("Deleted file size in KB: " + fileSizeInKB.toString()); | 
		
	
		
			
				|  |  |  |  |       debugPrint("Deleted file size in MB: " + fileSizeInMB.toString()); | 
		
	
		
			
				|  |  |  |  |       if (kDebugMode) { | 
		
	
		
			
				|  |  |  |  |         debugPrint("Deleted file size: ${delFile.lengthSync()}"); | 
		
	
		
			
				|  |  |  |  |         debugPrint("Deleted file size in KB: " + fileSizeInKB.toString()); | 
		
	
		
			
				|  |  |  |  |         debugPrint("Deleted file size in MB: " + fileSizeInMB.toString()); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |       if (await delFile.exists()) { | 
		
	
		
			
				|  |  |  |  |         delFile.delete(); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
	
		
			
				
					|  |  |  | @ -1095,12 +1095,13 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void sendVoiceMessage(BuildContext context, {required int targetUserId, required int userStatus, required String userEmail, required String targetUserName}) async { | 
		
	
		
			
				|  |  |  |  |     recorderController.pause(); | 
		
	
		
			
				|  |  |  |  |     //recorderController.pause(); | 
		
	
		
			
				|  |  |  |  |     path = await recorderController.stop(false); | 
		
	
		
			
				|  |  |  |  |     print(path); | 
		
	
		
			
				|  |  |  |  |     if (kDebugMode) { | 
		
	
		
			
				|  |  |  |  |       print(path); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     File voiceFile = File(path!); | 
		
	
		
			
				|  |  |  |  |     voiceFile.readAsBytesSync(); | 
		
	
		
			
				|  |  |  |  |     _pauseTimer(); | 
		
	
		
			
				|  |  |  |  |     _timer?.cancel(); | 
		
	
		
			
				|  |  |  |  |     isPause = false; | 
		
	
		
			
				|  |  |  |  |     isPlaying = false; | 
		
	
	
		
			
				
					|  |  |  | @ -1110,17 +1111,16 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |     logger.d(value); | 
		
	
		
			
				|  |  |  |  |     String? ext = getFileExtension(voiceFile.path); | 
		
	
		
			
				|  |  |  |  |     Utils.hideLoading(context); | 
		
	
		
			
				|  |  |  |  |     sendChatToServer( | 
		
	
		
			
				|  |  |  |  |         chatEventId: 2, | 
		
	
		
			
				|  |  |  |  |         fileTypeId: getFileType(ext.toString()), | 
		
	
		
			
				|  |  |  |  |         targetUserId: targetUserId, | 
		
	
		
			
				|  |  |  |  |         targetUserName: targetUserName, | 
		
	
		
			
				|  |  |  |  |         isAttachment: true, | 
		
	
		
			
				|  |  |  |  |         chatReplyId: null, | 
		
	
		
			
				|  |  |  |  |         isReply: false, | 
		
	
		
			
				|  |  |  |  |         isImageLoaded: true, | 
		
	
		
			
				|  |  |  |  |         image: voiceFile.readAsBytesSync()); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     // sendChatToServer( | 
		
	
		
			
				|  |  |  |  |     //     chatEventId: 2, | 
		
	
		
			
				|  |  |  |  |     //     fileTypeId: getFileType(ext.toString()), | 
		
	
		
			
				|  |  |  |  |     //     targetUserId: targetUserId, | 
		
	
		
			
				|  |  |  |  |     //     targetUserName: targetUserName, | 
		
	
		
			
				|  |  |  |  |     //     isAttachment: true, | 
		
	
		
			
				|  |  |  |  |     //     chatReplyId: null, | 
		
	
		
			
				|  |  |  |  |     //     isReply: false, | 
		
	
		
			
				|  |  |  |  |     //     isImageLoaded: true, | 
		
	
		
			
				|  |  |  |  |     //     image: voiceFile.readAsBytesSync()); | 
		
	
		
			
				|  |  |  |  |     notifyListeners(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
	
		
			
				
					|  |  |  | 
 |