waveform_pro 1.1.1
waveform_pro: ^1.1.1 copied to clipboard
Production-quality Flutter waveform widget with GPU-accelerated rendering, discrete bars, curved splines, dual-color progress, zoom, markers, and audio peak extraction.
waveform_pro #
A production-quality, GPU-accelerated Flutter audio waveform visualization library supporting continuous envelopes, discrete SoundCloud-style bars, bezier curved splines, dual-color playback progress, interactive zooming/panning, draggable region selection, cue markers, live audio stream buffering, and headless PNG exports.
Now available on pub.flutter-io.cn/packages/waveform_pro.
β¨ Features #
- π Multiple Render Modes:
WaveformRenderMode.continuousβ Classic mirrored continuous path.WaveformRenderMode.barsβ Discrete rounded vertical bars (SoundCloud & Apple Voice Memos style).WaveformRenderMode.curvedSplineβ Ultra-smooth cubic bezier spline curves.
- β―οΈ Dual-Color Playback Progress β Colorize played vs unplayed waveform segments (
playedWaveColorvswaveColor) based onplayheadPosition. - β‘ Multi-Resolution Pyramid Caching β Decimates waveform data at powers-of-two for 60fps rendering across any zoom level.
- π Interactive Timeline β Pinch-to-zoom, horizontal drag/pan, and programmatic
WaveformControllerwith automatic viewport adaptation. - π Regions & Cue Markers β Interactive region selection with draggable bounds and labeled cue bookmarks.
- ποΈ Live Audio Buffer Support β Dynamically append audio peaks to
WaveformData(data.append(...)) for real-time recorders. - πΌοΈ Headless PNG Image Exporter β Generate waveform images directly to
Uint8ListviaWaveformExporter.toPngBytes(...)without mounting widgets. - π¨ Built-in Presets β Ready-to-use themes like
WaveformStyle.voiceMemoandWaveformStyle.neonGlow.
π¦ Installation #
Add waveform_pro to your Flutter project:
flutter pub add waveform_pro
Or add it to your pubspec.yaml dependencies:
dependencies:
waveform_pro: ^1.1.0
Import:
import 'package:waveform_pro/waveform_pro.dart';
π Usage #
1. Basic Waveform Timeline (SoundCloud / Voice Memos Bar Style) #
import 'package:flutter/material.dart';
import 'package:waveform_pro/waveform_pro.dart';
class AudioPlayerWaveform extends StatelessWidget {
final WaveformData waveformData;
const AudioPlayerWaveform({super.key, required this.waveformData});
@override
Widget build(BuildContext context) {
return WaveformTimeline(
data: waveformData,
style: WaveformStyle.voiceMemo,
playheadPosition: 12.4, // seconds played
playheadColor: Colors.blueAccent,
showTimeRuler: true,
onTap: (seconds) {
print('User seeked to: ${seconds}s');
},
onRegionChanged: (start, end) {
print('Selected region: $start - $end');
},
);
}
}
2. Smooth Curved Spline Mode #
WaveformTimeline(
data: waveformData,
style: WaveformStyle.neonGlow,
playheadPosition: 5.0,
height: 140,
)
3. Live Streaming / Real-time Audio Recording #
WaveformData liveData = WaveformData(samples: [], durationSeconds: 0);
// As microphone buffer packets arrive:
void onAudioBufferReceived(List<double> newPeaks, double bufferDuration) {
setState(() {
liveData = liveData.append(newPeaks, addedDurationSeconds: bufferDuration);
});
}
4. Headless PNG Image Export (Thumbnails / Notifications) #
import 'dart:typed_data';
import 'package:waveform_pro/waveform_pro.dart';
Future<Uint8List> generateWaveformThumbnail(WaveformData data) async {
return await WaveformExporter.toPngBytes(
data: data,
width: 600,
height: 150,
style: WaveformStyle.voiceMemo,
playheadPosition: 20.0,
);
}
π οΈ API Overview #
| Class | Description |
|---|---|
WaveformTimeline |
Interactive Flutter widget with gesture support, time ruler, cue markers, and playhead. |
WaveformPainter |
Custom painter executing GPU-accelerated continuous, discrete bar, and spline rendering. |
WaveformRenderMode |
Enum (continuous, bars, curvedSpline) defining the visual geometry. |
WaveformStyle |
Styling configuration (bar width, gaps, radiuses, wave colors, played progress color). |
WaveformData |
Pyramid-cached sample container with .generate(), .append(), and multi-res getters. |
WaveformController |
Programmatic zoom, scroll, region selection, and marker management. |
WaveformExporter |
Headless rasterizer for exporting waveforms to PNG byte buffers. |
π§ͺ Testing #
flutter test
π License #
This package is licensed under the MIT License.