Skip to content

Repository files navigation

WAVE

Flutter package: tm - WAVE


Awesome: FlutterPubGitHub

A Flutter package for displaying animated wave backgrounds.

Demo

PlatformURL
Webwave.glorylab.xyz

The web demo is an interactive generator. Adjust the config mode, palette, layer count, height, amplitude, speed, and loop behavior, then copy the generated WaveWidget code into your app.

Wave Generator web demo with live preview, controls, performance metrics, and generated code dialog entry

Deployment

The web demo is built from example/ and deployed with Cloudflare Workers Static Assets. See docs/cloudflare-workers.md for the GitHub Actions and migration setup.

Install

dependencies:
wave: ^0.2.4

Minimal Example

import'package:flutter/material.dart';
import'package:wave/wave.dart';
classWaveBackgroundextendsStatelessWidget {
constWaveBackground({Key? key}) :super(key: key);
@overrideWidgetbuild(BuildContext context) {
returnWaveWidget(
config:SingleConfig(
color:Color(0xFF00BBF9),
layers:3,
),
size:Size(double.infinity, double.infinity),
);
}
}

Use WaveWidget anywhere a normal widget can be painted. Give it a bounded parent, such as SizedBox.expand, Positioned.fill, or a fixed-height container.

Config Modes

Single color

SingleConfig creates layered waves from one base color.

WaveWidget(
config:SingleConfig(
color:constColor(0xFF00BBF9),
layers:3,
),
size:constSize(double.infinity, double.infinity),
)

Seeded random colors

RandomConfig creates generated colors for each layer. Provide seed when deterministic output is useful for tests, demos, or copyable examples. Omit seed only when you really want a new generated palette for each config construction.

WaveWidget(
config:RandomConfig(
seed:7,
layers:4,
),
size:constSize(double.infinity, double.infinity),
)

Custom colors or gradients

CustomConfig is the most explicit mode. Use it when you want full control over each layer's color or gradient, duration, and height.

WaveWidget(
config:CustomConfig(
gradients:const [
[Color(0xFF00BBF9), Color(0xFF9B5DE5)],
[Color(0xFFFEE440), Color(0xFFF15BB5)],
],
durations:const [5000, 4000],
heightPercentages:const [0.65, 0.66],
),
size:constSize(double.infinity, double.infinity),
)

Parameters

WaveWidget

ParameterTypeDefaultDescription
configConfigrequiredLayer colors, durations, heights, and blur.
sizeSizerequiredPaint size for the wave stack.
waveAmplitudedouble20.0Base vertical movement of the wave path.
wavePhasedouble10.0Initial phase offset for the animation.
waveFrequencydouble1.6Horizontal frequency of the wave path.
durationint?6000Total runtime in milliseconds when isLoop is false.
backgroundColorColor?nullBackground color behind the waves.
backgroundImageDecorationImage?nullBackground image behind the waves.
isLoopbooltrueWhether animations repeat indefinitely.

Config classes

ClassBest forKey parameters
SingleConfigOne-color layered wavescolor, layers, opacityPercentages, durations, heightPercentages
RandomConfigFast generated paletteslayers, seed, colors, durations, heightPercentages
CustomConfigExact colors or gradientscolors or gradients, durations, heightPercentages, gradientBegin, gradientEnd

Common Errors

CustomConfig requires exactly one of colors or gradients.

CustomConfig(
colors:const [Color(0xFF00BBF9)],
gradients:const [
[Color(0xFF00BBF9), Color(0xFF9B5DE5)],
],
durations:const [5000],
heightPercentages:const [0.65],
)

All per-layer lists must have the same length.

CustomConfig(
colors:const [Color(0xFF00BBF9), Color(0xFF9B5DE5)],
durations:const [5000],
heightPercentages:const [0.65, 0.66],
)

heightPercentages and opacityPercentages values must be between 0 and 1, and every duration must be positive.

About

A Flutter package for displaying waves.

Topics

Resources

Code of conduct

Stars

1.1k stars

Watchers

8 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages