SoundRecorderUI constructor

SoundRecorderUI(
  1. Track track, {
  2. Color? backgroundColor,
  3. OnStart? onStart,
  4. OnStop? onStopped,
  5. OnPaused? onPaused,
  6. OnDelete? onDelete,
  7. UIRequestPermission? requestPermissions,
  8. bool showTrashCan = true,
  9. String pausedTitle = 'Recorder is paused',
  10. String recordingTitle = 'Recorder is recording',
  11. String stoppedTitle = 'Recorder is stopped',
  12. Key? key,
})

Records audio from the users microphone into the given media file.

The user is presented with a UI that allows them to start/stop recording and provides some basic feed back on the volume as the recording progresses.

The track specifies the file we are recording to. At the moment the track must be constructued using Track.fromFile as recording to a databuffer is not currently supported.

The onStart callback is called user starts recording. This method will be called each time the user clicks the 'record' button.

The onStopped callback is called when the user stops recording. This method will be each time the user clicks the 'stop' button. It can also be called if the stop method is called.

The requestPermissions callback allows you to request permissions just before they are required and if desired display your own dialog explaining why the permissions are required.

If you do not provide requestPermissions then you must ensure that all required permissions are granted before the SoundRecorderUI widgets starts recording.

  SoundRecorderIU(track,
      informUser: (context, track)
          {
              // pseudo code
              String reason;
              if (!microphonePermission.granted)
                reason += 'please allow microphone';
              if (!requestingStoragePermission.granted)
                reason += 'please allow storage';
              if (Dialog.show(reason) == Dialog.OK)
              {
                microphonePermission.request == granted;
                storagePermission.request == granted;
                return true;
              }

          });

Implementation

SoundRecorderUI(
  Track track, {
  this.backgroundColor,
  this.onStart,
  this.onStopped,
  this.onPaused,
  this.onDelete,
  this.requestPermissions,
  this.showTrashCan = true,
  this.pausedTitle = 'Recorder is paused',
  this.recordingTitle = 'Recorder is recording',
  this.stoppedTitle = 'Recorder is stopped',
  Key? key,
})  : audio = RecordedAudio.toTrack(track),
      super(key: key);