feat: ✨ Add WaveStyle.maxDuration for proportional recording width
Description
Adds WaveStyle.maxDuration so the recording waveform can be bound to a fixed maximum duration instead of scrolling.
Today the recording waveform grows until it hits the middle of the width and then scrolls left, so every recording ends up looking the same length no matter how long it actually was. There was no way to make the drawn length reflect the recording length.
What changed
- New optional
WaveStyle.maxDuration. - When set, the waveform no longer scrolls. It fills only
elapsedRecordingDuration / maxDurationof the available width. - Example: with
maxDurationof 10s, stopping at 5s draws across half the width; reaching 10s fills the full width; recording past 10s stays clamped to the full width. - LTR only (ignored for RTL, like
extendWaveform) and takes precedence overextendWaveformwhen both are set. - Fully backward compatible: default is
null, which keeps the existing scrolling behavior unchanged.
UI Changes
When maxDuration is set, the recording waveform stays inside the box and its length now reflects how far the recording is toward the cap, instead of growing and scrolling. No change when maxDuration is unset.
Before (without maxDuration)
https://github.com/user-attachments/assets/e4739222-58bb-41c6-8089-d8ed21f70ec2
After (optional maxDuration set to 10s)
https://github.com/user-attachments/assets/7bcff8a3-b039-490f-b187-1210afc6d1df
Checklist
- [x] The title of my PR starts with a [Conventional Commit] prefix (
fix:,feat:,docs:etc). - [x] I have followed the [Contributor Guide] when preparing my PR.
- [ ] I have updated/added tests for ALL new/updated/fixed functionality.
- [x] I have updated/added relevant documentation in
docsand added dartdoc comments with///. - [x] I have updated/added relevant examples in
examplesordocs.
Breaking Change?
- [ ] Yes, this PR is a breaking change.
- [x] No, this PR is not a breaking change.
Related Issues
Closes #91