Last active
July 7, 2020 14:45
-
-
Save stephaniefash/42be08ed67ea1e4377e1e971286c15e7 to your computer and use it in GitHub Desktop.
This file contains 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'; | |
import 'package:flutter/widgets.dart'; | |
class CounterWidget extends StatefulWidget { | |
@override | |
_CounterWidgetState createState() => _CounterWidgetState(); | |
} | |
class _CounterWidgetState extends State<CounterWidget> { | |
int _counter; | |
@override | |
void initState() { | |
super.initState(); | |
_counter = 0; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
Text(_counter.toString()), | |
RaisedButton( | |
onPressed: () { | |
setState(() { | |
_counter++; | |
}); | |
}, | |
child: Text('Press me'), | |
) | |
]), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment