-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimatedposition.dart
46 lines (43 loc) · 1.28 KB
/
animatedposition.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:flutter/material.dart';
class AnimatedPositionWidget extends StatefulWidget {
const AnimatedPositionWidget({super.key});
@override
State<AnimatedPositionWidget> createState() => _AnimatedPositionWidgetState();
}
class _AnimatedPositionWidgetState extends State<AnimatedPositionWidget> {
bool selected = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AnimatedPosition"),
),
body: SizedBox(
width: 250,
height: 350,
child: Stack(children: [
AnimatedPositioned(
width: selected ? 200 : 50,
height: selected ? 50 : 200,
top: selected ? 50 : 150,
duration: const Duration(seconds: 2),
curve: Curves.fastOutSlowIn,
child: GestureDetector(
onTap: () {
setState(() {
selected = !selected;
});
},
child: Container(
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(25)),
child: const Center(child: Text('Click')),
),
),
)
]),
),
);
}
}