-
Notifications
You must be signed in to change notification settings - Fork 4
/
decorated_box_transition_page.dart
68 lines (61 loc) · 1.81 KB
/
decorated_box_transition_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import 'package:flutter/material.dart';
import '../../widget/app_scaffold.dart';
class DecoratedBoxTransitionPage extends StatefulWidget {
const DecoratedBoxTransitionPage({super.key});
static const routeName = 'DecoratedBoxTransition';
@override
State<DecoratedBoxTransitionPage> createState() =>
_DecoratedBoxTransitionPageState();
}
class _DecoratedBoxTransitionPageState extends State<DecoratedBoxTransitionPage>
with SingleTickerProviderStateMixin {
late final AnimationController _animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 500),
);
var _isScaledUp = false;
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AppScaffold(
title: 'DecoratedBoxTransition',
floatingActionButton: FloatingActionButton(
onPressed: () {
if (_isScaledUp) {
_animationController.reverse();
} else {
_animationController.forward();
}
_isScaledUp = !_isScaledUp;
},
child: const Icon(Icons.refresh),
),
child: Center(
child: DecoratedBoxTransition(
decoration: _animationController
.drive(
CurveTween(curve: Curves.fastOutSlowIn),
)
.drive(
DecorationTween(
begin: const FlutterLogoDecoration(
style: FlutterLogoStyle.horizontal,
),
end: const FlutterLogoDecoration(
style: FlutterLogoStyle.stacked,
),
),
),
child: const SizedBox(
width: 200,
height: 200,
),
),
),
);
}
}