Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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'),
- ],
- );
- }
- }
Add Comment
Please, Sign In to add comment