Guest User

Untitled

a guest
Oct 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.40 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'dart:math';
  3. import 'dart:async';
  4.  
  5. int check1 = 0;
  6. void main() async => runApp(new MyApp());
  7.  
  8. class MyApp extends StatelessWidget {
  9. @override
  10. Widget build(BuildContext context) {
  11. return new MaterialApp(
  12. theme: new ThemeData(primarySwatch: Colors.blue),
  13. home: new LoginPage(),
  14. );
  15. }
  16. }
  17.  
  18. class LoginPage extends StatefulWidget {
  19. @override
  20. State createState() => new LoginPageState();
  21. }
  22.  
  23. class LoginPageState extends State<LoginPage>
  24. with SingleTickerProviderStateMixin {
  25. Animation<double> _iconAnimation;
  26. AnimationController _iconAnimationController;
  27. String selectedValues;
  28.  
  29. @override
  30. void initState() {
  31. super.initState();
  32.  
  33. _iconAnimationController = new AnimationController(
  34. vsync: this, duration: new Duration(milliseconds: 500));
  35. _iconAnimation = new CurvedAnimation(
  36. parent: _iconAnimationController,
  37. curve: Curves.bounceOut,
  38. );
  39. _iconAnimation.addListener(() => this.setState(() {}));
  40. _iconAnimationController.forward();
  41. }
  42.  
  43. //Background Image Code Starts From here
  44. @override
  45. Widget build(BuildContext context) {
  46. return new Scaffold(
  47. backgroundColor: Colors.white,
  48. body: new Stack(fit: StackFit.expand, children: <Widget>[
  49. new Image(
  50. image: new AssetImage('asset/bg.png'),
  51. fit: BoxFit.cover,
  52. ),
  53. new Theme(
  54. child: Container(
  55. padding: const EdgeInsets.fromLTRB(100.0, 10.0, 100.0, 00.0),
  56. decoration: BoxDecoration(
  57. image: DecorationImage(
  58. image: new AssetImage('asset/I2.png'),
  59. alignment: Alignment.topRight,
  60. ),
  61. ),
  62. ),
  63. data: new ThemeData(
  64. canvasColor: Colors.blue.shade200,
  65. brightness: Brightness.dark,
  66. inputDecorationTheme: new InputDecorationTheme()),
  67. isMaterialAppTheme: true,
  68. ),
  69. new Column(
  70. children: <Widget>[
  71. new Padding(
  72. padding: new EdgeInsets.only(
  73. top: 50.0,
  74. )),
  75. new Padding(
  76. padding: new EdgeInsets.only(
  77. top: 50.0,
  78. )),
  79. new DropdownButton<String>(
  80. onChanged: (String value) {
  81. setState(() {
  82. new Text(
  83. selectedValues,
  84. style: TextStyle(
  85. fontSize: 24.0,
  86. fontWeight: FontWeight.w900,
  87. fontFamily: "Georgia",
  88. color: Colors.grey[300],
  89. ),
  90. );
  91. });
  92. },
  93. hint: new Text('Select Type'),
  94. value: selectedValues,
  95. items: <String>[
  96. "Questions",
  97. "Something else",
  98. ].map((String value) {
  99. return new DropdownMenuItem<String>(
  100. value: value.toString(),
  101. child: new Text(value),
  102. );
  103. }).toList(),
  104. ),
  105. ],
  106. ),
  107. ImageRotate(),
  108. ]),
  109. );
  110. }
  111. }
  112.  
  113. //Background Image Code Ends From here
  114.  
  115. //Animation code starts from here
  116. class ImageRotate extends StatefulWidget {
  117. @override
  118. _ImageRotateState createState() => new _ImageRotateState();
  119. }
  120.  
  121. class _ImageRotateState extends State<ImageRotate>
  122. with SingleTickerProviderStateMixin {
  123. AnimationController animationController;
  124.  
  125. static var rng = new Random();
  126. double random_number = 0.0;
  127.  
  128. @override
  129. void initState() {
  130. super.initState();
  131.  
  132. animationController = new AnimationController(
  133. vsync: this,
  134. duration: Duration(seconds: random_number.toInt()),
  135. )..addStatusListener((status) {
  136. if ((status == AnimationStatus.completed) ||
  137. (status == AnimationStatus.dismissed)) {
  138. // custom code here
  139. }
  140. });
  141. }
  142.  
  143. void move() {
  144. double random_number = (5 +
  145. ((rng.nextInt((5 - 1).ceil() * 1000) +
  146. rng.nextInt((30 - 10).ceil() * 1000) +
  147. rng.nextInt((30 - 10).ceil() * 1000) +
  148. rng.nextInt((30 - 10).ceil())) /
  149. 4000.0));
  150. double random_number1 = (4 +
  151. ((rng.nextInt((5 - 1).ceil() * 1000) +
  152. rng.nextInt((30 - 10).ceil() * 1000) +
  153. rng.nextInt((30 - 10).ceil() * 1000) +
  154. rng.nextInt((30 - 10).ceil())) /
  155. 4000.0));
  156.  
  157. print(random_number);
  158.  
  159. print("Hello");
  160. print(MediaQuery.of(context).size.height);
  161. print(MediaQuery.of(context).size.width);
  162. animationController.duration = Duration(seconds: random_number.toInt());
  163. animationController.forward(from: -1.0);
  164.  
  165. animationController.forward();
  166. print(animationController.value);
  167. print(animationController.value * random_number1);
  168. animationController.addListener(() {
  169. this.setState(() {
  170. animationController.addStatusListener((status) {
  171. if ((status == AnimationStatus.dismissed)) {
  172. new Padding(
  173. padding: new EdgeInsets.only(
  174. top: 100.0,
  175. ));
  176. return new Text("bla bla bla");
  177.  
  178. }
  179. });
  180. });
  181. });
  182. }
  183.  
  184.  
  185. @override
  186. Widget build(BuildContext context) {
  187. double random_number3 = (60 +
  188. ((rng.nextInt((5 - 1).ceil() * 1000) +
  189. rng.nextInt((30 - 10).ceil() * 1000) +
  190. rng.nextInt((30 - 10).ceil() * 1000) +
  191. rng.nextInt((30 - 10).ceil())) /
  192. 4000.0));
  193. return new Container(
  194. padding: new EdgeInsets.only(
  195. left: 0.0,
  196. right: 0.0,
  197. bottom: MediaQuery.of(context).size.height -
  198. (39 * MediaQuery.of(context).size.height) / 100),
  199. alignment: Alignment.bottomCenter,
  200. child: new AnimatedBuilder(
  201. animation: animationController,
  202. child: new GestureDetector(
  203. child: new Image.asset('asset/5.png'),
  204. onTap: () {
  205. move();
  206.  
  207. },
  208.  
  209. ),
  210. builder: (BuildContext context, Widget _widget) {
  211. return new Transform.rotate(
  212. angle: animationController.value * random_number3.toInt(),
  213. child: _widget,
  214.  
  215. );
  216. },
  217.  
  218. ),
  219. );
  220. }
  221. }
  222.  
  223. //Animation code Ends from here
  224. class QuestionDisplay extends StatefulWidget {
  225. @override
  226. _QuestionDisplayState createState() => _QuestionDisplayState();
  227. }
  228.  
  229. class _QuestionDisplayState extends State<QuestionDisplay> {
  230. @override
  231. Widget build(BuildContext context) {
  232. new Padding(
  233. padding: new EdgeInsets.only(
  234. top: 100.0,
  235. ));
  236. print("qwerty");
  237. return new Text("123");
  238. }
  239. }
Add Comment
Please, Sign In to add comment