wave 0.0.4 wave: ^0.0.4 copied to clipboard
Widget for displaying a wave, with custom duration, size, color, alpha and so on.
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:wave/wave.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Wave Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Wave Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List colors = [
Colors.amber,
Colors.blue,
Colors.brown,
Colors.blueGrey,
Colors.cyan,
Colors.deepOrange,
Colors.deepPurple,
Colors.green,
Colors.grey,
Colors.indigo,
Colors.orange,
Colors.pink,
Colors.purple,
Colors.red,
Colors.teal,
Colors.yellow,
];
_buildWave() {
return Card(
elevation: 8.0,
margin: EdgeInsets.all(16.0),
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0))),
child: Wave(
height: (Random().nextDouble() + 0.2) * 128,
duration: 300 + Random().nextInt(6000),
color: colors[Random().nextInt(colors.length - 1)],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
onPressed: () {
setState(() {});
},
)
],
),
body: Center(
child: ListView(
children: List.generate(5, (index) {
return _buildWave();
}),
),
),
);
}
}