|
| 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