how to automatically start audio recording once user is inside the audio page?

Viewed 21

I have a audio recording page which starts when I tap in the button and stop when i tap the button once again

ElevatedButton(
      child: Icon(
        recorder.isRecording ? Icons.stop : Icons.mic,
        size: 80,
      ),
      onPressed: () async {
        if (recorder.isRecording) {
          await stop();
          context.pop();
        } else {
          await record();
        }
        setState(() {});
      },

how can I automatically start recording once I open the audio recording page and tap it to stop and tap again to start?

I tried to put the record function in initstate but it didn't work

void initState() {
     super.initState(); 
     initRecorder(); 
     record(); 
        }
0 Answers
Related