Last active
September 11, 2019 05:02
-
-
Save Kurogoma4D/a2c99090c3567cb969537b21922a4935 to your computer and use it in GitHub Desktop.
ドゥルルルルルルルル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter_web/material.dart'; | |
import 'package:flutter_web_ui/ui.dart' as ui; | |
import 'dart:math' as math; | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'ドゥルルルルルル', | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('ドゥルルルルルル'), | |
), | |
body: Center( | |
child: CrazyMan(), | |
), | |
), | |
); | |
} | |
} | |
class CrazyMan extends StatefulWidget { | |
@override | |
_CrazyManState createState() => _CrazyManState(); | |
} | |
class _CrazyManState extends State<CrazyMan> with TickerProviderStateMixin { | |
AnimationController _armController; | |
AnimationController _bodyController; | |
Animation<double> _bodyAnimation; | |
@override | |
void initState() { | |
super.initState(); | |
_armController = AnimationController( | |
duration: const Duration(milliseconds: 500), | |
vsync: this, | |
)..repeat(); | |
_bodyController = AnimationController( | |
duration: const Duration(milliseconds: 2500), | |
vsync: this, | |
); | |
_bodyAnimation = Tween<double>(begin: 0, end: 600).animate(_bodyController) | |
..addListener(() => setState(() {})); | |
_bodyController.repeat(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Transform.translate( | |
offset: Offset(_bodyAnimation.value, 0), | |
child: _buildCrazy(context), | |
); | |
} | |
Widget _buildCrazy(BuildContext context) { | |
return AnimatedBuilder( | |
animation: _armController, | |
builder: (context, child) { | |
return Row( | |
children: <Widget>[ | |
const Text('三('), | |
Transform.rotate( | |
angle: _armController.value * 2.0 * math.pi, | |
origin: Offset.zero, | |
child: Text('卍'), | |
), | |
const Text('^o^)'), | |
Transform.rotate( | |
angle: _armController.value * 2.0 * math.pi, | |
origin: Offset.zero, | |
child: Text('卍'), | |
), | |
const Text('ドゥルルルルルルルル'), | |
], | |
); | |
}, | |
); | |
} | |
@override | |
void dispose() { | |
_armController.dispose(); | |
_bodyController.dispose(); | |
super.dispose(); | |
} | |
} | |
Future<void> main() async { | |
await ui.webOnlyInitializePlatform(); | |
runApp(MyApp()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment