Skip to content

Instantly share code, notes, and snippets.

@fabiomsr
Created May 1, 2019 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiomsr/8ce342d1308126c682890619ad55d054 to your computer and use it in GitHub Desktop.
Save fabiomsr/8ce342d1308126c682890619ad55d054 to your computer and use it in GitHub Desktop.
class MyHomePage extends StatelessWidget {
final _counter = new ValueNotifier(0);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("ValueListenableBuilder example"),
),
body: CounterListenableProvider(
counter: _counter,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('You have pushed the button this many times:'),
CounterText()
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () => _counter.value++,
tooltip: 'Increment',
child: Icon(Icons.add),
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment