siri_wave

pub package Platform GitHub top language CirrusCI CodeFactor Visits

A Flutter package to create beautiful waveforms like in Siri. It was inspired from the siriwave library.

Demo

Check out the live demo here.

iOS 7 style

iOS 7

iOS 9 style

iOS 9

Getting Started

Requirements

  • Dart >= 2.17.0
  • Flutter >= 3.0.0

Usage

Simply create a SiriWave widget:

import 'package:siri_wave/siri_wave.dart';

class MyWidget extends StatelessWidget {
  Widget build(BuildContext context) {
    return SiriWave();
  }
}

To be able to change the amplitude, frequency, speed and color properties of the waveform, create a SiriWaveController and pass it to the SiriWave widget:

import 'package:siri_wave/siri_wave.dart';

class MyWidget extends StatelessWidget {
  Widget build(BuildContext context) {
    // You can change the default values while creating the controller.
    //  final controller = SiriWaveController(
    //    amplitude: 0.5,
    //    color: Colors.red,
    //    frequency: 4,
    //    speed: 0.15,
    //  );
    final controller = SiriWaveController();
    return SiriWave(controller: controller);
  }
}

And then call any method you want from the controller.

controller.setAmplitude(0.8);
controller.setSpeed(0.1);

// Only available in the iOS 7 style waveform.
controller.setColor(Colors.yellow);
controller.setFrequency(4);

See the example directory for a complete sample app.

SiriWave

Parameter Type Description Default
controller SiriWaveController The controller of the SiriWave. SiriWaveController()
options SiriWaveOptions The configuration of the SiriWave. SiriWaveOptions()
style SiriWaveStyle The wave style of the SiriWave. SiriWaveStyle.ios_9

SiriWaveController

Parameter Type Description Default
amplitude double The amplitude of the waveform. 1.0
color Color The color of the iOS 7 style waveform. Colors.white
frequency int The frequency of the iOS 7 style waveform. 6
speed double The speed of the waveform. 0.2
Function Description
setAmplitude(double value) Sets the amplitude of the waveform. The value must be in the 0,1 range.
setColor(Color color) Sets the color of the iOS 7 style waveform.
setFrequency(double value) Sets the frequency of the iOS 7 style waveform. The value must be in the -20,20 range.
setSpeed(double value) Sets the speed of the waveform. The value must be in the 0,1 range.

SiriWaveOptions

Parameter Type Description Default
height double The height of the waveform. 180
showSupportBar bool Whether to show support bar on iOS 9 style waveform. true
width double The width of the waveform. 360

🤝 Contributing

Contributions, issues and feature requests are welcome. Feel free to check issues page if you want to contribute.

Libraries

siri_wave