Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Last active June 23, 2019 08:39
Show Gist options
  • Save ryanlid/b6269ba9369074b7e7e19dbd8388ab85 to your computer and use it in GitHub Desktop.
Save ryanlid/b6269ba9369074b7e7e19dbd8388ab85 to your computer and use it in GitHub Desktop.
A Decision Making App
import 'package:flutter/material.dart';
import 'dart:math';
void main() => runApp(
MaterialApp(
home: Scaffold(
backgroundColor: Colors.blueAccent,
appBar: AppBar(
title: Text("Ask Me Anything"),
),
body: MagicBall(),
),
),
);
class MagicBall extends StatefulWidget {
@override
_MagicBallState createState() => _MagicBallState();
}
class _MagicBallState extends State<MagicBall> {
var ballNumber = 1;
void changeMagicNumber() {
setState(() {
ballNumber = Random().nextInt(5) + 1;
});
}
@override
Widget build(BuildContext context) {
return Center(
child: FlatButton(
onPressed: () {
changeMagicNumber();
},
child: Image.asset('images/ball$ballNumber.png'),
),
);
}
}
@ryanlid
Copy link
Author

ryanlid commented Jun 23, 2019

Screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment