Created
January 2, 2021 17:57
-
-
Save jacobaraujo7/672d8ee21becd1df107da341e316f1b5 to your computer and use it in GitHub Desktop.
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
class HomePage extends StatelessWidget { | |
final counter = ValueNotifier<int>(0); | |
_increment() => counter.value++; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text('Counter')), | |
body: Center( | |
child: ValueListenableBuilder( | |
valueListenable: counter, | |
builder: (BuildContext context, int value, Widget child) { | |
return Text('$value'); | |
} | |
), | |
), | |
floatingActionButton: FloatingActionButton( | |
child: Icon(Icons.plus_one), | |
onPressed: _increment, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment