From c5b4c55b5d72b327dfd6fbff98faa1b48a5c881c Mon Sep 17 00:00:00 2001 From: "Shams Zakhour (ignore Sfshaza)" Date: Fri, 13 Feb 2026 10:09:47 -0800 Subject: [PATCH 1/3] Adding a recipe for the record package --- site/lib/src/style_hash.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/lib/src/style_hash.dart b/site/lib/src/style_hash.dart index 0a86c7f940d..ce114383cc9 100644 --- a/site/lib/src/style_hash.dart +++ b/site/lib/src/style_hash.dart @@ -2,4 +2,4 @@ // dart format off /// The generated hash of the `main.css` file. -const generatedStylesHash = 'D1OovaDfTpf7'; +const generatedStylesHash = ''; From 86bd3395d5f60553a573af9440f24deb97d3c902 Mon Sep 17 00:00:00 2001 From: "Shams Zakhour (ignore Sfshaza)" Date: Tue, 17 Feb 2026 15:53:43 -0800 Subject: [PATCH 2/3] Oops. Added page --- src/content/cookbook/audio/index.md | 6 + src/content/cookbook/audio/record.md | 163 +++++++++++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 src/content/cookbook/audio/index.md create mode 100644 src/content/cookbook/audio/record.md diff --git a/src/content/cookbook/audio/index.md b/src/content/cookbook/audio/index.md new file mode 100644 index 00000000000..47a40e59615 --- /dev/null +++ b/src/content/cookbook/audio/index.md @@ -0,0 +1,6 @@ +--- +title: Flutter audio cookbook +shortTitle: Audio +description: A catalog of Flutter recording recipes. +layout: toc +--- diff --git a/src/content/cookbook/audio/record.md b/src/content/cookbook/audio/record.md new file mode 100644 index 00000000000..738a2c8fedf --- /dev/null +++ b/src/content/cookbook/audio/record.md @@ -0,0 +1,163 @@ +--- +title: Record or stream audio input +description: +--- + + + +This recipe demonstrates how to use the [`record` package][] to add +audio recording and streaming capabilities to your Flutter app. +Here is an overview of the steps involved in implementing audio input: + +[record package]: {{site.pub}}/packages/record + +1. Add the package dependency +1. Initialize an `AudioRecorder` object +1. Request user permission +1. Create and configure a `RecordConfig` +1. Start recording to a file +1. Control an ongoing recording +1. [Optional] Record to an audio stream +1. Stop the recording +1. Dispose of the recorder + +## 1. Add the package dependency + +Add record to your `pubspec.yaml` file: + +```yaml +dependencies: + record: ^latest_version +``` + +Then run `flutter pub get` + +## 2. Initialize an `AudioRecorder` + +Initialize an `AudioRecorder` object. This is the primary object +that controls the recording process. + +```dart +import 'package:record/record.dart'; + +final recorder = AudioRecorder(); +``` + +## 3. Request user permission + +Before recording, you need to request user permission. +You might also need to add platform-specific permission configurations. +Refer to the [record package][] documentation for details. + +```dart +final recorder = AudioRecorder(); +if (await recorder.hasPermission()) { + // Permission granted, proceed with recording +} else { + // Permission denied +} +``` + +## 4. Create and configure a recorder + +Create and configure a `RecordConfig` object to specify the record settings, +such as the encoder, sample rate, and channel number. +You can also enable features like auto gain, echo cancellation, +and noise suppression. + +```dart +final recordConfig = RecordConfig( + encoder: AudioEncoder.pcm16bits, + sampleRate: 24000, + numChannels: 1, + autoGain: true, + echoCancel: true, + noiseSuppress: true, +); +``` + +## 5. Start recording to a file + +Get the desired file path and call the `start` method +on the `AudioRecorder`, passing in the `recordConfig` +and the path where the file should be stored. + +```dart +import 'package:path_provider/path_provider.dart'; // For getting a temporary directory + +final directory = await getTemporaryDirectory(); +final path = '${directory.path}/myRecord.m4a'; +await recorder.start(recordConfig, path: path); +print('Recording started to: $path'); +``` + +## 6. Control an ongoing recording + +You can control an ongoing recording using `pause()`, `resume()`, +and `stop()`. + +```dart +await recorder.pause(); +await recorder.resume(); +await recorder.stop(); +``` + +## 7. [Optional] Record to an audio stream + +To stream audio, use the `startStream` method. +This returns a stream of audio data. + +```dart +final stream = await recorder.startStream(recordConfig); +stream.listen((audioChunk) { + // Process audioChunk (e.g., send to a server) +}); +``` + +## 8. Stop recording + +To stop the recording and get the path to the saved file, +call the asynchronous `stop()` method on the `AudioRecorder`. + +```dart +final path = await recorder.stop(); +print('Recording stopped. File saved to: $path'); +``` + +## 9. Dispose of the recorder + +When you are finished using the `AudioRecorder`, +remember to dispose() of it to release resources. + +```dart +await recorder.dispose(); +``` + +## Supported formats and encodings + +The `record` package supports various file formats +and encodings across different platforms +(iOS, Android, Web, macOS, Windows, and Linux). +Some examples include: + +* `aacLc` +* `aacEld` +* `aacHe` +* `amrNb` +* `amrWb` +* `opus` +* `wav` +* `flac` +* `pcm16bits` + +For more detailed information and the full list of supported options, +visit the [record package][] page on pub.dev or check out the +following Package of the Week video. + +
+
+
+ +
+
+
From 7817a9df7bb3db2b384a6173e93893cc295704b1 Mon Sep 17 00:00:00 2001 From: "Shams Zakhour (ignore Sfshaza)" Date: Tue, 17 Feb 2026 16:02:28 -0800 Subject: [PATCH 3/3] Fixing broken link --- src/content/cookbook/audio/record.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/cookbook/audio/record.md b/src/content/cookbook/audio/record.md index 738a2c8fedf..f5b97542809 100644 --- a/src/content/cookbook/audio/record.md +++ b/src/content/cookbook/audio/record.md @@ -9,7 +9,7 @@ This recipe demonstrates how to use the [`record` package][] to add audio recording and streaming capabilities to your Flutter app. Here is an overview of the steps involved in implementing audio input: -[record package]: {{site.pub}}/packages/record +[`record` package]: {{site.pub}}/packages/record 1. Add the package dependency 1. Initialize an `AudioRecorder` object @@ -47,7 +47,7 @@ final recorder = AudioRecorder(); Before recording, you need to request user permission. You might also need to add platform-specific permission configurations. -Refer to the [record package][] documentation for details. +Refer to the [`record` package][] documentation for details. ```dart final recorder = AudioRecorder(); @@ -151,7 +151,7 @@ Some examples include: * `pcm16bits` For more detailed information and the full list of supported options, -visit the [record package][] page on pub.dev or check out the +visit the [`record` package][] page on pub.dev or check out the following Package of the Week video.