Skip to content

Instantly share code, notes, and snippets.

@zontyp
Created August 28, 2020 13:07
Show Gist options
  • Save zontyp/45b63cc4b7d605caa5bac87c4a8ca0fc to your computer and use it in GitHub Desktop.
Save zontyp/45b63cc4b7d605caa5bac87c4a8ca0fc to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(new HelloWorld());
}
class HelloWorld extends StatefulWidget {
@override
_HelloWorldState createState() => _HelloWorldState();
}
class _HelloWorldState extends State<HelloWorld> {
String message = "Guess The Number";
void calculateResult (int guessNumber)
{
setState((){
this.message = "my number is higher";
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Hello World Example'),
),
body:Center (
child:Column (
children:[
Text (
""
),
Text (
"$message"
),
FlatButton(
color: Colors.black,
textColor:Colors.lightGreenAccent,
onPressed: () {
calculateResult(1);
},
child: Text(
"1",
style: TextStyle(fontSize: 22.0),
),
),
FlatButton(
color: Colors.black,
textColor:Colors.lightGreenAccent,
onPressed: () {
calculateResult(2);
},
child: Text(
"2",
style: TextStyle(fontSize: 22.0),
),
),
FlatButton(
color: Colors.black,
textColor:Colors.lightGreenAccent,
onPressed: () {
calculateResult(3);
},
child: Text(
"3",
style: TextStyle(fontSize: 22.0),
),
),
]
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment