SoundRecorderUI

Overview

The SoundRecorderUI widget provide a simple UI for recording audio.

The audio is recorded to a Track.

permissions

When recording audio you need access to the devices microphone and possibly its storage.

Sounds does not manage permissions for you. You must ensure that the appropriate permissions are obtained.

The package permission_handler provides a convenient set of methods for manageing permissions.

When requesting permissions the OS will display a prompt to the user. I generally recommend that you only prompt the user for the required permissions at the point in time that they require them.

To allow you complete control over the timing of the permission request to the user you can provide a call back to the requestPermission argument which is called when the user clicks the 'record' button. Recording will not start until the callback completes.

onStart

The onStart method is called when recording starts.

Widget build(BuildContext context)
{
    return SoundRecorderUI(track, onStart: () => print('recording started'))
}

onStopped

The onStopped method is called when the recording stops.

Example:

This example is from the example app. It demonstrates how to create a Recorder SoundRecorderUI linked to a SoundPlayerUI.

The example demonstrates how to build a UI which allows a user to record audio and then immediately play it back.

The example also uses requestPermissions to display an explanatory dialog to the user before the OS displays its standard permission dialog.

The RecorderPlaybackController is responsible for coordinating the recording and playback so that only one can occur at a time.

Last updated

Was this helpful?