Skip to content

Instantly share code, notes, and snippets.

@kn0ch3n
Created June 22, 2018 17:32
Show Gist options
  • Save kn0ch3n/f0ae81adde270b33d46b5d38b7ddcb9b to your computer and use it in GitHub Desktop.
Save kn0ch3n/f0ae81adde270b33d46b5d38b7ddcb9b to your computer and use it in GitHub Desktop.
Flutter example
class CounterState extends State<Counter> {
int counter = 0;
void increment() {
// Tells the Flutter framework that state has changed,
// so the framework can run build() and update the display.
setState(() {
counter++;
});
}
Widget build(BuildContext context) {
// This method is rerun every time setState is called.
// The Flutter framework has been optimized to make rerunning
// build methods fast, so that you can just rebuild anything that
// needs updating rather than having to individually change
// instances of widgets.
return new Row(
children: <Widget>[
new RaisedButton(
onPressed: increment,
child: new Text('Increment'),
),
new Text('Count: $counter'),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment