Skip to content

Instantly share code, notes, and snippets.

@Blasanka
Last active March 22, 2018 12:22
Show Gist options
  • Save Blasanka/e637bf5a519c02a4e2b84729b27540bf to your computer and use it in GitHub Desktop.
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 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