-
Notifications
You must be signed in to change notification settings - Fork 4
/
animated_container.dart
55 lines (49 loc) · 1.5 KB
/
animated_container.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
import 'package:animations_app/widget/animation_object.dart';
import 'package:animations_app/widget/app_scaffold.dart';
import 'package:flutter/material.dart';
class AnimatedContainerPage extends StatefulWidget {
const AnimatedContainerPage({super.key});
static const routeName = 'animatedContainer';
@override
State<AnimatedContainerPage> createState() => _AnimatedContainerPageState();
}
class _AnimatedContainerPageState extends State<AnimatedContainerPage> {
static const _alignments = [
Alignment.topLeft,
Alignment.topRight,
Alignment.bottomRight,
Alignment.bottomLeft,
];
static const _colors = [
Colors.red,
Colors.green,
Colors.blue,
Colors.yellow,
];
var _index = 0;
AlignmentGeometry get _alignment => _alignments[_index % _alignments.length];
Color get _color => _colors[_index % _colors.length];
@override
Widget build(BuildContext context) {
return AppScaffold(
title: 'AnimatedContainer',
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_index++;
});
},
child: const Icon(Icons.refresh),
),
child: AnimatedContainer(
alignment: _alignment,
color: _color,
margin: EdgeInsets.all(20 * ((3 - _index).toDouble() % 4)),
padding: EdgeInsets.all(20 * (_index.toDouble() % 4)),
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut,
child: const AnimationObject(),
),
);
}
}