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.4
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
π Ecosystem & Related Packages
Explore complementary production-grade libraries built for high-performance Flutter & Dart development:
| Package | Description | Version |
|---|---|---|
ambient_backdrop_glow |
Dynamic ambient background glow and fluid animated mesh gradients from image artwork with OKLab color blending for Flutter. | ^1.1.2 |
country_mobile_validator |
Validate mobile numbers per country using real length ranges (8-10, 10-11 digits), mobile-only detection, and a country_code_picker-friendly API. | ^0.2.1 |
cron_schedule |
Lightweight, pure-Dart cron parser, next-occurrence predictor, human-readable translator, and fluent schedule builder for Dart and Flutter. | ^1.1.1 |
currency_field_formatter |
Bulletproof Flutter currency TextInputFormatter with exact cursor tracking, backspace handling, Indian Lakhs/Crores, and ISO 4217 presets. | ^1.1.1 |
flutter_whisper |
On-device speech-to-text transcription using whisper.cpp. Automatic model download, streaming segment results, Android support. | ^0.2.1 |
offline_outbox |
Resilient offline-first outbox and retry queue for Dart and Flutter with disk persistence, exponential backoff, priority scheduling, and deduplication. | ^1.1.1 |
quote_painter |
Flutter package for rendering styled text on image/video canvas with gradient fill, stroke, shadow, decorative quotation marks, line badges, and themes. | ^0.2.4 |
scratch_reveal |
High-performance GPU-accelerated scratch card and scratch-to-reveal canvas widget for Flutter with sub-millisecond bitmask progress tracking. | ^1.1.1 |
segmented_ring_painter |
High-performance segmented circular progress and concentric activity ring widget for Flutter with gradient arcs, rounded caps, gap math, and tap hit-testing. | ^1.1.2 |
π Support the Project
If you find this project useful, consider supporting its active maintenance and future development:
π License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Maintained with β€οΈ by Govind Tank.