Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class _BallBodyState extends State<BallBody> {
- List<String> balls = [
- 'images/ball1.png',
- 'images/ball2.png',
- 'images/ball3.png',
- 'images/ball4.png',
- 'images/ball5.png'
- ];
- int _current = 0;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text('Magic 8 Ball'),
- ),
- body: InkWell(
- onTap: () {
- setState(() {
- _current = Random().nextInt(5);
- });
- },
- child: AnimatedContainer(
- duration: Duration(seconds: 2),
- child: Center(
- child: Image.asset(balls[_current]),
- ),
- ),
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement