Git Product home page Git Product logo

audio_wave's Introduction

Audio wave

A multi purpose simple bar graph with animation. It is highly customizable. You can customize the width and height of widget. And the height, color, and radius of bar also.

audio_wave.gif

Examples

Column(
  children: [
    Text('Audio Wave Example'),
    AudioWave(
      bars: [AudioWaveBar(heightFactor: 1)],
    ),
    AudioWave(
      bars: [
        AudioWaveBar(heightFactor: 1, color: Colors.green),
        AudioWaveBar(heightFactor: 0.1, color: Colors.black),
      ],
    ),
    AudioWave(
      height: 32,
      width: 32,
      spacing: 2.5,
      animationLoop: 3,
      bars: [
        AudioWaveBar(heightFactor: 0.7, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.8, color: Colors.blue),
        AudioWaveBar(heightFactor: 1, color: Colors.black),
        AudioWaveBar(heightFactor: 0.9),
      ],
    ),
    AudioWave(
      height: 32,
      width: 88,
      spacing: 2.5,
      bars: [
        AudioWaveBar(heightFactor: 0.1, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.2, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.3, color: Colors.black),
        AudioWaveBar(heightFactor: 0.4),
        AudioWaveBar(heightFactor: 0.5, color: Colors.orange),
        AudioWaveBar(heightFactor: 0.6, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.7, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.8, color: Colors.black),
        AudioWaveBar(heightFactor: 0.9),
        AudioWaveBar(heightFactor: 1, color: Colors.orange),
        AudioWaveBar(heightFactor: 0.1, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.2, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.3, color: Colors.black),
        AudioWaveBar(heightFactor: 0.4),
        AudioWaveBar(heightFactor: 0.5, color: Colors.orange),
        AudioWaveBar(heightFactor: 0.6, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.7, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.8, color: Colors.black),
        AudioWaveBar(heightFactor: 0.9),
        AudioWaveBar(heightFactor: 1, color: Colors.orange),
      ],
    ),
    AudioWave(
      height: 32,
      width: 88,
      spacing: 2.5,
      alignment: 'top',
      animationLoop: 2,
      beatRate: Duration(milliseconds: 50),
      bars: [
        AudioWaveBar(heightFactor: 0.1, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.2, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.3, color: Colors.black),
        AudioWaveBar(heightFactor: 0.4),
        AudioWaveBar(heightFactor: 0.5, color: Colors.orange),
        AudioWaveBar(heightFactor: 0.6, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.7, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.8, color: Colors.black),
        AudioWaveBar(heightFactor: 0.9),
        AudioWaveBar(heightFactor: 1, color: Colors.orange),
        AudioWaveBar(heightFactor: 0.1, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.2, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.3, color: Colors.black),
        AudioWaveBar(heightFactor: 0.4),
        AudioWaveBar(heightFactor: 0.5, color: Colors.orange),
        AudioWaveBar(heightFactor: 0.6, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.7, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.8, color: Colors.black),
        AudioWaveBar(heightFactor: 0.9),
        AudioWaveBar(heightFactor: 1, color: Colors.orange),
      ],
    ),
    AudioWave(
      height: 32,
      width: 160,
      spacing: 5,
      alignment: 'bottom',
      animationLoop: 2,
      beatRate: Duration(milliseconds: 50),
      bars: [
        AudioWaveBar(heightFactor: 1, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.9, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.8, color: Colors.black),
        AudioWaveBar(heightFactor: 0.7),
        AudioWaveBar(heightFactor: 0.6, color: Colors.orange),
        AudioWaveBar(heightFactor: 0.5, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.4, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.3, color: Colors.black),
        AudioWaveBar(heightFactor: 0.2),
        AudioWaveBar(heightFactor: 0.1, color: Colors.orange),
        AudioWaveBar(heightFactor: 1, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.1, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.2, color: Colors.black),
        AudioWaveBar(heightFactor: 0.3),
        AudioWaveBar(heightFactor: 0.4, color: Colors.orange),
        AudioWaveBar(heightFactor: 0.5, color: Colors.lightBlueAccent),
        AudioWaveBar(heightFactor: 0.6, color: Colors.blue),
        AudioWaveBar(heightFactor: 0.7, color: Colors.black),
        AudioWaveBar(heightFactor: 0.8),
        AudioWaveBar(heightFactor: 0.9, color: Colors.orange),
      ],
    ),
  ],
),

audio_wave's People

Contributors

ahmadre avatar bensonarafat avatar tahamv avatar thruthesky avatar zvikarp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

audio_wave's Issues

Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null

Hi there,

After upgrading to flutter 3.0.0 I've experienced the following error.

/opt/homebrew/Caskroom/flutter/3.0.0/flutter/.pub-cache/hosted/pub.dartlang.org/audio_wave-0.1.3/lib/audio_wave.dart:84:22: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/opt/homebrew/Caskroom/flutter/3.0.0/flutter/packages/flutter/lib/src/widgets/binding.dart').
      WidgetsBinding.instance?.addPostFrameCallback((x) {

It think this error says enough. An update would be great! Thanks in advance.

An issue from community.

I'm using the audio wave library. Very nice. Thanks.

Here is what I found. When I pop the view the time is still running which is causing setState to be called. The debugger is indicating that a memory leak is likely occurring.

The fix that I did was to add a local bool variable cancelTimer; a dispose() function. In the dispose function I set the cancelTimer = true. In the setState I check the cancelTimer and cancel the timer if needed.

This cleared up the issue.

bool cancelTimer = false;

@OverRide
void dispose() {
cancelTimer = true;
super.dispose();

print('Audio wave Dispose called.');
}

if (mounted) {
setState(() {
if(cancelTimer) {
timer.cancel();
}
});
}

Build Failed After upgrading v -0.1.2 to v 0.1.4

There is a warning after upgrading the build failed.

Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/audio_wave-0.1.4/lib/audio_wave.dart:84:31: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
      WidgetsBinding.instance.addPostFrameCallback((x) {
                              ^^^^^^^^^^^^^^^^^^^^


FAILURE: Build failed with an exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.