Created
February 10, 2020 02:26
-
-
Save kitoko552/f5fc23b33048e499c3e1d2a9839b7078 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
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