Skip to content

Instantly share code, notes, and snippets.

@ibushraabbasi
Forked from angelabauer/solution5.dart
Created January 11, 2021 20:49
Show Gist options
  • Save ibushraabbasi/5d0b9f78901025f954d76d242fdcd5eb to your computer and use it in GitHub Desktop.
Save ibushraabbasi/5d0b9f78901025f954d76d242fdcd5eb to your computer and use it in GitHub Desktop.
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
home: BallPage(),
),
);
class BallPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
backgroundColor: Colors.blue.shade900,
title: Text('Ask Me Anything'),
),
body: Ball(),
);
}
}
class Ball extends StatefulWidget {
@override
_BallState createState() => _BallState();
}
class _BallState extends State<Ball> {
int ballNumber = 1;
@override
Widget build(BuildContext context) {
return Center(
child: FlatButton(
onPressed: () {
ballNumber = Random().nextInt(5);
print(ballNumber);
},
child: Image.asset('images/ball1.png'),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment