ecg_paper 0.1.0
ecg_paper: ^0.1.0 copied to clipboard
Scrollable ECG "paper" widget (25 mm/s, 10 mm/mV) for Flutter. Feed mV samples and sample rate to render clinical-style grids and trace.
ecg_paper #
Scrollable ECG “paper” widget for Flutter. Renders a clinical-style grid at 25 mm/s and 10 mm/mV. Feed mV samples and sample rate and it draws a 30s (configurable) trace you can horizontally scroll.
中文说明:见 README_ZH.md

Features #
- Clinical layout: 25 mm/s, 10 mm/mV (configurable)
- Auto-detect units (assumes V → converts to mV)
- Decimation for performance (min/max bucket) — keeps shape on large signals
- Optional fixed Y range (
fixedYRangeMv) or auto-fit - Smooth path rendering with grid & second ticks
- Stateless API + easy theming via
EcgStyle
Quick start #
import 'package:ecg_paper/ecg_paper.dart';
final fs = 512.0; // Hz
final samplesMv = getSamplesInMilliVolt();
EcgScrollableWidget(
samples: samplesMv,
sampleRateHz: fs,
durationSeconds: 10, // default 30
style: const EcgStyle(height: 220),
enableDecimation: true, // on by default
autoDetectUnits: true, // on by default
);
If your raw data is in Volt #
Either multiply by 1000 before passing in, or leave as-is and keep autoDetectUnits: true (default).
Parameters #
samples(List: ECG samples (mV recommended)sampleRateHz(double)durationSeconds(double): time window (default 30)style(EcgStyle): speed, gain, grid, stroke, colors…fixedYRangeMv(double?): set to e.g.2.0to lock ±2 mV; null = auto-fit
autoDetectUnits(bool): if true, convert V→mV when magnitude suggests VoltenableDecimation(bool): enable min/max bucket decimation for performancemaxPoints(int?): hard cap after decimation (optional)scrollToEndOnBuild(bool): auto scroll right on first build
Export a PNG (example app) #
Run the example and tap Save PNG to export the current widget as a PNG under app documents. To make a GIF, record screen or export multiple PNGs and use ffmpeg:
ffmpeg -framerate 12 -i frame_%03d.png -vf "palettegen" palette.png
ffmpeg -framerate 12 -i frame_%03d.png -i palette.png -lavfi "paletteuse" ecg.gif
Tips #
- For extremely long buffers, decimation avoids building giant paths. You can also pre-trim to the desired window.
- To lock Y range (clinical review), set
fixedYRangeMv: 2.0(±2 mV).
License #
MIT