@@ -42,7 +42,7 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
4242 String ? path;
4343 String ? musicFile;
4444 bool isRecording = false ;
45- late Directory tempDir ;
45+ late Directory appDirectory ;
4646
4747 @override
4848 void initState () {
@@ -52,9 +52,9 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
5252 }
5353
5454 void _getDir () async {
55- tempDir = await getApplicationDocumentsDirectory ();
55+ appDirectory = await getApplicationDocumentsDirectory ();
5656 _preparePlayers ();
57- path = "${tempDir .path }/music.aac" ;
57+ path = "${appDirectory .path }/music.aac" ;
5858 }
5959
6060 Future <ByteData > _loadAsset (String path) async {
@@ -95,25 +95,25 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
9595
9696 void _preparePlayers () async {
9797 ///audio-1
98- final file1 = File ('${tempDir .path }/audio1.mp3' );
98+ final file1 = File ('${appDirectory .path }/audio1.mp3' );
9999 await file1.writeAsBytes (
100100 (await _loadAsset ('assets/audios/audio1.mp3' )).buffer.asUint8List ());
101101 playerController1.preparePlayer (file1.path);
102102
103103 ///audio-2
104- final file2 = File ('${tempDir .path }/audio2.mp3' );
104+ final file2 = File ('${appDirectory .path }/audio2.mp3' );
105105 await file2.writeAsBytes (
106106 (await _loadAsset ('assets/audios/audio2.mp3' )).buffer.asUint8List ());
107107 playerController2.preparePlayer (file2.path);
108108
109109 ///audio-3
110- final file3 = File ('${tempDir .path }/audio3.mp3' );
110+ final file3 = File ('${appDirectory .path }/audio3.mp3' );
111111 await file3.writeAsBytes (
112112 (await _loadAsset ('assets/audios/audio3.mp3' )).buffer.asUint8List ());
113113 playerController3.preparePlayer (file3.path);
114114
115115 ///audio-4
116- final file4 = File ('${tempDir .path }/audio4.mp3' );
116+ final file4 = File ('${appDirectory .path }/audio4.mp3' );
117117 await file4.writeAsBytes (
118118 (await _loadAsset ('assets/audios/audio4.mp3' )).buffer.asUint8List ());
119119 playerController4.preparePlayer (file4.path);
0 commit comments