Voice recording using Flutter

Devansh Baldwa picture Devansh Baldwa · Oct 20, 2019 · Viewed 6.9k times · Source

I am trying to build an app using Flutter which will have voice recorder in it. How do I access voice recorder? Please help me figure out the Packages, Dependencies and Code for it.

Answer

Florin Bratan picture Florin Bratan · Oct 20, 2019

You can use the audio_recorder package:

https://pub.dev/packages/audio_recorder

// Import package
import 'package:audio_recorder/audio_recorder.dart';

// Check permissions before starting
bool hasPermissions = await AudioRecorder.hasPermissions;

// Get the state of the recorder
bool isRecording = await AudioRecorder.isRecording;

// Start recording
await AudioRecorder.start(path: _controller.text, audioOutputFormat: AudioOutputFormat.AAC);

// Stop recording
Recording recording = await AudioRecorder.stop();
print("Path : ${recording.path},  Format : ${recording.audioOutputFormat},  Duration : ${recording.duration},  Extension : ${recording.extension},");