audio_waveforms icon indicating copy to clipboard operation
audio_waveforms copied to clipboard

feat: ✨ Add WaveStyle.maxDuration for proportional recording width

Open lavigarg-simform opened this issue 5 months ago • 0 comments

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 / maxDuration of the available width.
  • Example: with maxDuration of 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 over extendWaveform when 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 docs and added dartdoc comments with ///.
  • [x] I have updated/added relevant examples in examples or docs.

Breaking Change?

  • [ ] Yes, this PR is a breaking change.
  • [x] No, this PR is not a breaking change.

Related Issues

Closes #91

lavigarg-simform avatar Jun 29 '26 14:06 lavigarg-simform