-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnumber_animation.dart
60 lines (56 loc) · 1.71 KB
/
number_animation.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import 'package:flutter/material.dart';
import 'package:number_animation/number_animation.dart';
void main() {
runApp(AppDemo());
}
class AppDemo extends StatefulWidget {
@override
_AppDemoState createState() => _AppDemoState();
}
class _AppDemoState extends State<AppDemo> {
double number = 100;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'NumberAnimation Demo',
theme: ThemeData(
primarySwatch: Colors.pink,
),
home: Scaffold(
appBar: AppBar(
title: Text('NumberAnimation Demo'),
),
body: Container(
padding: EdgeInsets.all(20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
FloatingActionButton(
onPressed: () {
setState(() {
number = number - 10;
});
},
tooltip: 'reduction',
child: Icon(Icons.remove),
),
NumberAnimation(
start: 0, // default is 0, can remove
end: number,
style: TextStyle(color: Colors.pinkAccent, fontSize: 30),
after: '%',
),
FloatingActionButton(
onPressed: () {
setState(() {
number = number + 10;
});
},
tooltip: 'Increment',
child: Icon(Icons.add),
),
],
),
)));
}
}