Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 115f636

Browse files
Add dancing-man example
1 parent 1719400 commit 115f636

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

‎assets/dancing-man.gif

2.59 MB
Loading[フレーム]

‎assets/screenshots/dancing-man.png

382 KB
Loading[フレーム]

‎assets/stop-man.png

790 KB
Loading[フレーム]

‎lib/pages/dancing_man.dart

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import 'package:flutter/material.dart';
2+
3+
class DancingMan extends StatefulWidget {
4+
const DancingMan({ Key? key }) : super(key: key);
5+
6+
@override
7+
_DancingManState createState() => _DancingManState();
8+
}
9+
10+
class _DancingManState extends State<DancingMan> with SingleTickerProviderStateMixin {
11+
bool _isDancing = false;
12+
13+
// margin animation from bottom
14+
late AnimationController _marginAnimationController;
15+
Animation<double>? _marginAnimation;
16+
17+
@override
18+
void initState() {
19+
super.initState();
20+
21+
_marginAnimationController = AnimationController(
22+
duration: const Duration(seconds: 2),
23+
vsync: this,
24+
);
25+
26+
_marginAnimation = Tween<double>(
27+
begin: 20.0,
28+
end: 0.0,
29+
).animate(
30+
CurvedAnimation(
31+
parent: _marginAnimationController,
32+
curve: Curves.easeInOut,
33+
),
34+
);
35+
36+
_marginAnimationController.repeat();
37+
}
38+
39+
@override
40+
Widget build(BuildContext context) {
41+
return Scaffold(
42+
backgroundColor: Color(0xffF8AD19),
43+
body: Container(
44+
height: MediaQuery.of(context).size.height,
45+
child: GestureDetector(
46+
onPanUpdate: (details) {
47+
if (details.delta.dy > -5) {
48+
setState(() {
49+
_isDancing = false;
50+
});
51+
} else {
52+
setState(() {
53+
_isDancing = true;
54+
});
55+
}
56+
},
57+
child: Column(
58+
mainAxisAlignment: MainAxisAlignment.center,
59+
children: [
60+
_isDancing ?
61+
Image.asset('assets/dancing-man.gif',
62+
height: 500, fit: BoxFit.cover,)
63+
: Image.asset('assets/stop-man.png', height: 500,),
64+
65+
SizedBox(height: 50,),
66+
// animated arrow up Icon
67+
_isDancing ?
68+
Column(
69+
children: [
70+
Text("Swipe Down to Stop"),
71+
SizedBox(height: 20,),
72+
Icon(Icons.keyboard_arrow_down, color: Colors.black, size: 30,),
73+
],
74+
)
75+
:
76+
Column(
77+
children: [
78+
AnimatedBuilder(
79+
animation: _marginAnimation!,
80+
builder: (context, child) {
81+
return Transform.translate(
82+
offset: Offset(0, _marginAnimation!.value),
83+
child: Icon(Icons.keyboard_arrow_up, color: Colors.black, size: 30,),
84+
);
85+
},
86+
),
87+
SizedBox(height: 20,),
88+
Text("Swipe Up To Play"),
89+
],
90+
)
91+
],
92+
),
93+
)
94+
),
95+
);
96+
}
97+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /