Skip to content

Commit 5e6eb73

Browse files
committed
Add: AnimatedIcon sample
1 parent af9a2b3 commit 5e6eb73

File tree

3 files changed

+110
-2
lines changed

3 files changed

+110
-2
lines changed

lib/component/main/MainPage.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class _MainState extends State<MainPage> {
6565
"DropDown",
6666
"Popup",
6767
"Wave",
68+
"IconAnim",
6869
];
6970
return _sortTitles;
7071
}
@@ -90,6 +91,7 @@ class _MainState extends State<MainPage> {
9091
"/DropDownPage",
9192
"/MainPopupPage",
9293
"/MainWavePage",
94+
"/MainIconAnimPage",
9395
];
9496
return _sortRouteNames;
9597
}
@@ -347,7 +349,7 @@ class _MainState extends State<MainPage> {
347349
ListTile(
348350
onTap: () {
349351
setState(
350-
() {
352+
() {
351353
_drawerOpenedRight = !_drawerOpenedRight;
352354
},
353355
);
@@ -357,7 +359,7 @@ class _MainState extends State<MainPage> {
357359
value: _drawerOpenedRight,
358360
onChanged: (bool value) {
359361
setState(
360-
() {
362+
() {
361363
_drawerOpenedRight = value;
362364
},
363365
);

lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import 'package:provider/provider.dart';
3030

3131
import 'ChineseCupertinoLocalizations.dart';
3232
import 'sample/anim/draw_anim_page.dart';
33+
import 'sample/anim/icon/main_icon_anim_page.dart';
3334
import 'sample/anim/snappable_page.dart';
3435
import 'sample/chart/chart_page.dart';
3536
import 'sample/clip/clip_main_page.dart';
@@ -124,6 +125,7 @@ class Test extends StatelessWidget {
124125
"/DropDownPage": (_) => DropDownPage(),
125126
"/MainPopupPage": (_) => MainPopupPage(),
126127
"/MainWavePage": (_) => MainWavePage(),
128+
"/MainIconAnimPage": (_) => MainIconAnimPage(),
127129
},
128130
);
129131
},
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import 'package:flutter/material.dart';
2+
3+
/// MainIconAnimPage
4+
/// Icons with animation
5+
class MainIconAnimPage extends StatefulWidget {
6+
@override
7+
State<StatefulWidget> createState() {
8+
return _MainIconAnimState();
9+
}
10+
}
11+
12+
class _MainIconAnimState extends State<MainIconAnimPage>
13+
with SingleTickerProviderStateMixin {
14+
AnimationController _animationController;
15+
@override
16+
void initState() {
17+
super.initState();
18+
_animationController = AnimationController(vsync: this);
19+
_animationController.duration = Duration(seconds: 1);
20+
}
21+
22+
@override
23+
void dispose() {
24+
super.dispose();
25+
_animationController.stop();
26+
_animationController.dispose();
27+
}
28+
29+
@override
30+
Widget build(BuildContext context) {
31+
return Scaffold(
32+
appBar: AppBar(
33+
title: Text("IconAnim"),
34+
),
35+
body: Row(
36+
children: <Widget>[
37+
Spacer(),
38+
Column(
39+
children: <Widget>[
40+
Spacer(),
41+
AnimatedIcon(
42+
icon: AnimatedIcons.menu_arrow,
43+
progress: _animationController),
44+
AnimatedIcon(
45+
icon: AnimatedIcons.play_pause,
46+
progress: _animationController),
47+
AnimatedIcon(
48+
icon: AnimatedIcons.pause_play,
49+
progress: _animationController),
50+
AnimatedIcon(
51+
icon: AnimatedIcons.add_event,
52+
progress: _animationController),
53+
AnimatedIcon(
54+
icon: AnimatedIcons.arrow_menu,
55+
progress: _animationController),
56+
AnimatedIcon(
57+
icon: AnimatedIcons.close_menu,
58+
progress: _animationController),
59+
AnimatedIcon(
60+
icon: AnimatedIcons.ellipsis_search,
61+
progress: _animationController),
62+
AnimatedIcon(
63+
icon: AnimatedIcons.event_add,
64+
progress: _animationController),
65+
AnimatedIcon(
66+
icon: AnimatedIcons.home_menu,
67+
progress: _animationController),
68+
AnimatedIcon(
69+
icon: AnimatedIcons.list_view,
70+
progress: _animationController),
71+
AnimatedIcon(
72+
icon: AnimatedIcons.menu_close,
73+
progress: _animationController),
74+
AnimatedIcon(
75+
icon: AnimatedIcons.menu_home,
76+
progress: _animationController),
77+
AnimatedIcon(
78+
icon: AnimatedIcons.menu_arrow,
79+
progress: _animationController),
80+
AnimatedIcon(
81+
icon: AnimatedIcons.view_list,
82+
progress: _animationController),
83+
Spacer(),
84+
],
85+
),
86+
Spacer(),
87+
],
88+
),
89+
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
90+
floatingActionButton: FloatingActionButton(
91+
onPressed: () {
92+
if (_animationController.isAnimating ||
93+
_animationController.isCompleted) {
94+
_animationController.reverse();
95+
} else {
96+
_animationController.forward();
97+
}
98+
},
99+
child: AnimatedIcon(
100+
icon: AnimatedIcons.play_pause, progress: _animationController),
101+
),
102+
);
103+
}
104+
}

0 commit comments

Comments
 (0)