Skip to content

Instantly share code, notes, and snippets.

@jacobaraujo7
Created January 2, 2021 17:57
Show Gist options
  • Save jacobaraujo7/672d8ee21becd1df107da341e316f1b5 to your computer and use it in GitHub Desktop.
Save jacobaraujo7/672d8ee21becd1df107da341e316f1b5 to your computer and use it in GitHub Desktop.
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