-
Notifications
You must be signed in to change notification settings - Fork 188
/
animated_switcher_page.dart
43 lines (39 loc) · 1.21 KB
/
animated_switcher_page.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
import 'package:flutter/material.dart';
class AnimatedSwitcherPage extends StatefulWidget {
@override
_AnimatedSwitcherPageState createState() => _AnimatedSwitcherPageState();
}
class _AnimatedSwitcherPageState extends State<AnimatedSwitcherPage> {
IconData _actionIcon = Icons.delete;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('AnimatedSwitcherPage'),
actions: <Widget>[
AnimatedSwitcher(
transitionBuilder: (child, anim){
return ScaleTransition(child: child,scale: anim);
},
duration: Duration(milliseconds: 300),
child: IconButton(
key: ValueKey(_actionIcon),
icon: Icon(_actionIcon),
onPressed: () {
setState(() {
if (_actionIcon == Icons.delete)
_actionIcon = Icons.done;
else
_actionIcon = Icons.delete;
});
}),
)
],
),
body: Container());
}
}