import 'dart:io'; import 'package:SEFER/controller/home/captin/map_driver_controller.dart'; import 'package:flutter_sound/flutter_sound.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; class AudioController extends GetxController { final recorder = FlutterSoundRecorder(); bool isRecoding = false; @override void onInit() { super.onInit(); initRecorder(); } Future initRecorder() async { final status = await Permission.microphone.request(); if (status != PermissionStatus.granted) { // Handle permission denied return; } await recorder.openRecorder(); recorder.setSubscriptionDuration(const Duration(milliseconds: 500)); } Future startRecording() async { await recorder.startRecorder( toFile: 'audio_${Get.find().rideId}.wav'); // Specify the file name isRecoding = true; update(); } Future stopRecording() async { final filePath = await recorder.stopRecorder(); final audioFile = File(filePath!); print('Recorded file path: $audioFile'); // Now you can send this file to the server isRecoding = false; update(); } @override void onClose() { recorder.closeRecorder(); super.onClose(); } }