Created
August 28, 2020 13:07
-
-
Save zontyp/45b63cc4b7d605caa5bac87c4a8ca0fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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