@@ -7,7 +7,7 @@ enum Actions { Increment }
7
7
8
8
// The reducer, which takes the previous count and increments it in response
9
9
// to an Increment action.
10
- int counterReducer (int state, action) {
10
+ int counterReducer (int state, dynamic action) {
11
11
if (action == Actions .Increment ) {
12
12
return state + 1 ;
13
13
}
@@ -16,14 +16,23 @@ int counterReducer(int state, action) {
16
16
}
17
17
18
18
void main () {
19
- runApp (new FlutterReduxApp ());
20
- }
21
-
22
- class FlutterReduxApp extends StatelessWidget {
23
19
// Create your store as a final variable in a base Widget. This works better
24
20
// with Hot Reload than creating it directly in the `build` function.
25
21
final store = new Store <int >(counterReducer, initialState: 0 );
26
22
23
+ runApp (new FlutterReduxApp (store: store));
24
+ }
25
+
26
+ class FlutterReduxApp extends StatefulWidget {
27
+ final Store <int > store;
28
+
29
+ FlutterReduxApp ({Key key, this .store}) : super (key: key);
30
+
31
+ @override
32
+ _FlutterReduxAppState createState () => new _FlutterReduxAppState ();
33
+ }
34
+
35
+ class _FlutterReduxAppState extends State <FlutterReduxApp > {
27
36
@override
28
37
Widget build (BuildContext context) {
29
38
final title = 'Flutter Redux Demo' ;
@@ -34,7 +43,7 @@ class FlutterReduxApp extends StatelessWidget {
34
43
home: new StoreProvider (
35
44
// Pass the store to the StoreProvider. Any ancestor `StoreConnector`
36
45
// Widgets will find and use this value as the `Store`.
37
- store: store,
46
+ store: widget. store,
38
47
child: new Scaffold (
39
48
appBar: new AppBar (
40
49
title: new Text (title),
0 commit comments