Last active
March 22, 2018 12:22
-
-
Save Blasanka/e637bf5a519c02a4e2b84729b27540bf to your computer and use it in GitHub Desktop.
This dart code for the slcoder's tutorial: different between StatelessWidget and StatefulWidget. You can find the gist for StatefulWidget here: https://gist.github.com/Blasanka/42a1d68d6868da0d02bfa8c5cb4f452c.
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
| // this example is created by slcoder to explain statelessWidget in slcoder's tutorials. | |
| // goto raised button example gist to get statefulWidget code | |
| import 'package:flutter/material.dart'; | |
| void main() => runApp(new MyApp()); | |
| int count = 0; | |
| class MyApp extends StatelessWidget { | |
| void _increase() { | |
| count++; | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return new MaterialApp( | |
| title: 'Hello World App', | |
| home: new Scaffold( | |
| appBar: new AppBar( | |
| title: new Text('StatelessWidget'), | |
| backgroundColor: new Color(0xFF8B1122), | |
| ), | |
| body: new Center( | |
| child: new Column( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: <Widget>[ | |
| new Text( | |
| "Up Votes : $count", | |
| style: new TextStyle( | |
| fontSize: 25.0, | |
| color: new Color(0xFF8B1122), | |
| fontWeight: FontWeight.w600, | |
| ), | |
| ), | |
| new RaisedButton( | |
| child: new Text('Vote up', style: new TextStyle(fontSize: 20.0,)), | |
| color: new Color(0xFF8B1122), | |
| textColor: Colors.white, | |
| padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 30.0), | |
| elevation: 10.0, | |
| splashColor: Colors.white70, | |
| onPressed: _increase, | |
| ), | |
| ], | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment