Advertisement
Guest User

Untitled

a guest
Jul 10th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.72 KB | None | 0 0
  1. class _BallBodyState extends State<BallBody> {
  2.   List<String> balls = [
  3.     'images/ball1.png',
  4.     'images/ball2.png',
  5.     'images/ball3.png',
  6.     'images/ball4.png',
  7.     'images/ball5.png'
  8.   ];
  9.   int _current = 0;
  10.   @override
  11.   Widget build(BuildContext context) {
  12.     return Scaffold(
  13.         appBar: AppBar(
  14.           title: Text('Magic 8 Ball'),
  15.         ),
  16.         body: InkWell(
  17.           onTap: () {
  18.             setState(() {
  19.               _current = Random().nextInt(5);
  20.             });
  21.           },
  22.           child: AnimatedContainer(
  23.             duration: Duration(seconds: 2),
  24.             child: Center(
  25.               child: Image.asset(balls[_current]),
  26.             ),
  27.           ),
  28.         ));
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement