diff --git a/lib/main.dart b/lib/main.dart index 8229e03..c50b80d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; void main() => runApp( @@ -26,14 +28,18 @@ class Ball extends StatefulWidget { } class _BallState extends State { + int ballNumber = 1; + @override Widget build(BuildContext context) { return Container( child: Center( child: FlatButton( - child: Image.asset('images/ball1.png'), + child: Image.asset('images/ball$ballNumber.png'), onPressed: () { - print('I got clicked'); + setState(() { + ballNumber = Random().nextInt(5) + 1; + }); }, ), ),