-
Notifications
You must be signed in to change notification settings - Fork 4
/
scale_transition_page.dart
85 lines (78 loc) · 2.26 KB
/
scale_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import 'package:flutter/material.dart';
import '../../widget/app_scaffold.dart';
class ScaleTransitionPage extends StatefulWidget {
const ScaleTransitionPage({super.key});
static const routeName = 'ScaleTransition';
@override
State<ScaleTransitionPage> createState() => _ScaleTransitionPageState();
}
class _ScaleTransitionPageState extends State<ScaleTransitionPage>
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: 'ScaleTransition',
floatingActionButton: FloatingActionButton(
onPressed: () {
if (_isScaledUp) {
_animationController.reverse();
} else {
_animationController.forward();
}
_isScaledUp = !_isScaledUp;
},
child: const Icon(Icons.refresh),
),
child: Column(
children: [
ScaleTransition(
alignment: Alignment.bottomCenter,
scale: _animationController
.drive(
CurveTween(
curve: const Interval(0, 0.8, curve: Curves.fastOutSlowIn),
),
)
.drive(
Tween<double>(
begin: 0.3,
end: 1,
),
),
child: Image.asset('assets/love.png'),
),
const SizedBox(height: 16),
ScaleTransition(
alignment: Alignment.topCenter,
scale: _animationController
.drive(
CurveTween(
curve: const Interval(0.4, 1, curve: Curves.fastOutSlowIn),
),
)
.drive(
Tween<double>(
begin: 0.3,
end: 1,
),
),
child: const Text(
'I am a dog 🐶',
style: TextStyle(fontSize: 32),
),
)
],
),
);
}
}