Skip to content

Instantly share code, notes, and snippets.

@kitoko552
Created February 10, 2020 02:26
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 kitoko552/f5fc23b33048e499c3e1d2a9839b7078 to your computer and use it in GitHub Desktop.
Save kitoko552/f5fc23b33048e499c3e1d2a9839b7078 to your computer and use it in GitHub Desktop.
class MyHomePage extends StatelessWidget {
const MyHomePage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Demo'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('You have pushed the button this many times:'),
StoreConnector<AppState, int>(
distinct: true,
converter: (store) => store.state.count,
builder: (context, count) {
return Text(
'$count',
style: Theme.of(context).textTheme.display1,
);
},
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
final store = StoreProvider.of<AppState>(context);
store.dispatch(UpdateCount(store.state.count + 1));
},
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment