-
Notifications
You must be signed in to change notification settings - Fork 4
/
animated_positioned.dart
46 lines (41 loc) · 1.28 KB
/
animated_positioned.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
import 'package:animations_app/widget/app_scaffold.dart';
import 'package:flutter/material.dart';
class AnimatedPositionedPage extends StatefulWidget {
const AnimatedPositionedPage({super.key});
static const routeName = 'animatedPositioned';
@override
State<AnimatedPositionedPage> createState() => _AnimatedPositionedPageState();
}
class _AnimatedPositionedPageState extends State<AnimatedPositionedPage> {
var _shrinked = true;
@override
Widget build(BuildContext context) {
return AppScaffold(
title: 'AnimatedPositioned',
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_shrinked = !_shrinked;
});
},
child: const Icon(Icons.refresh),
),
child: Center(
child: Stack(
children: [
Image.asset('assets/love_gray.png'),
// nullと数値指定の変化のアニメーションには非対応なので注意
AnimatedPositioned(
top: 0,
left: 0,
width: _shrinked ? 50 : 300,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut,
child: Image.asset('assets/love.png'),
),
],
),
),
);
}
}