Creating Smooth Animations with Wave Package in Flutter

Nurettin Eraslan
2 min readJun 29, 2023

--

In Flutter, you can use the Wave package to create visually stunning and smooth animations. This package allows you to generate wave-like animations that bring liveliness to your user interface. In this article, I will guide you step by step on how to utilize the Wave package to create animations and integrate them into a widget.

Step 1: Add the wave package to your project dependencies. In the dependencies section of your pubspec.yaml file, add the following line:

dependencies:
flutter:
sdk: flutter
wave: ^0.3.3

Step 2: To create a wave-like animation using the Wave package, you can use the following sample code:

import 'package:flutter/material.dart';
import 'package:wave/wave.dart';
import 'package:wave/config.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Wave Animation Example'),
),
body: Center(
child: WaveWidget(
config: CustomConfig(
gradients: [
[Colors.blue, Colors.blue.shade200],
[Colors.blue.shade200, Colors.blue.shade100],
],
durations: [35000, 19440],
heightPercentages: [0.25, 0.35],
blur: MaskFilter.blur(BlurStyle.solid, 10),
),
waveAmplitude: 0,
size: Size(double.infinity, double.infinity),
),
),
),
);
}
}

n the above code, we are using the Wave package to create a wave-like animation. The WaveWidget is a widget that encapsulates the wave animation. The CustomConfig class allows you to customize the appearance and behavior of the animation. In the example code, we create a wave animation with two different gradients. You can also customize parameters such as wave height percentage and animation duration.

The Wave package simplifies the process of creating visually appealing animations in Flutter. It provides a quick and easy way to add motion and liveliness to your user interface.

In this article, you learned how to create wave-like animations in your Flutter application using the Wave package and integrate them into a widget. With this package, you can provide your users with a visually engaging experience.

--

--

Nurettin Eraslan
Nurettin Eraslan

No responses yet