Skip to content

Commit

Permalink
Step 6 - Working 8 ball
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossBread committed Oct 3, 2020
1 parent 2ed4571 commit a7dffe0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:flutter/material.dart';

void main() => runApp(
Expand Down Expand Up @@ -26,14 +28,18 @@ class Ball extends StatefulWidget {
}

class _BallState extends State<Ball> {
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;
});
},
),
),
Expand Down

0 comments on commit a7dffe0

Please sign in to comment.