record-audio
Use this skill when the user asks how to add the record package to a Flutter project and use it to record audio.
Install
mkdir -p .claude/skills/record-audio && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15674" && unzip -o skill.zip -d .claude/skills/record-audio && rm skill.zipInstalls to .claude/skills/record-audio
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use this skill when the user asks how to add the record package to a Flutter project and use it to record audio.About this skill
Record Audio with record Package
Goal
To successfully add the record package to a project and implement functionality to record audio to a file.
Instructions
When tasked with implementing audio recording using the record package, follow these steps:
-
Add the Package Dependency: Add
recordto the project's dependencies:flutter pub add record -
Initialize an AudioRecorder: Instantiate the primary object that controls the recording process. You typically want to hold onto a single instance of
AudioRecorder.import 'package:record/record.dart'; final recorder = AudioRecorder(); -
Request User Permission: Before recording, you must verify that the user has granted microphone permissions. Keep in mind that you may also need to configure platform-specific permissions (like
Info.pliston iOS/macOS orAndroidManifest.xmlon Android).if (await recorder.hasPermission()) { // Permission granted, proceed with recording. } else { // Permission denied, handle accordingly. } -
Create a Recording Configuration: Create a
RecordConfigobject to specify the recording settings such as the encoder, sample rate, and channels. You can also enable features like auto gain, echo cancellation, and noise suppression.final recordConfig = const RecordConfig( encoder: AudioEncoder.pcm16bits, sampleRate: 24000, numChannels: 1, autoGain: true, echoCancel: true, noiseSuppress: true, ); -
Start Recording to a File: Call the
startmethod on theAudioRecorder, providing the configuration and the destination file path.// Provide a valid path for the audio file depending on the platform. final audioFilePath = 'myRecording.wav'; await recorder.start(recordConfig, path: audioFilePath); -
Control an Ongoing Recording (Optional): You can pause and resume the recording if needed.
await recorder.pause(); await recorder.resume(); -
Stop Recording: To stop the recording and retrieve the final path of the saved file, call the asynchronous
stopmethod.final path = await recorder.stop(); print('Recording stopped. File saved to: $path'); -
Dispose of the Recorder: When you are completely finished using the
AudioRecorder(for instance, in thedisposemethod of aStatefulWidget), you must release its resources to prevent memory leaks or microphone locking.await recorder.dispose();
Constraints
- Ensure proper permission checks (
hasPermission()) are performed before attempting to start a recording. - Always
dispose()of theAudioRecorderinstance when it is no longer needed.