Skip to content

Instantly share code, notes, and snippets.

@Kav47
Created January 27, 2020 00:39
Show Gist options
  • Select an option

  • Save Kav47/e379dd14421ea996f651cbee49814dfd to your computer and use it in GitHub Desktop.

Select an option

Save Kav47/e379dd14421ea996f651cbee49814dfd to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'dart:math';
void main() => runApp(
MaterialApp(
home: BallPage(),
),
);
class BallPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
title: Text('Ask Me Anything'),
backgroundColor: Colors.blue.shade900,
),
body: Ball(),
);
}
}
class Ball extends StatefulWidget {
@override
_BallState createState() => _BallState();
}
class _BallState extends State<Ball> {
int ballNumber = 0;
@override
Widget build(BuildContext context) {
return FlatButton(
onPressed: (){
ballNumber = Random().nextInt(4);
print('ball number: $ballNumber');
},
child: Center(
child: Image.asset('images/ball$ballNumber.png'),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment