11import 'package:flutter/material.dart' ;
2+ import 'package:gsy_github_app_flutter/common/redux/GSYState.dart' ;
3+ import 'package:gsy_github_app_flutter/common/model/User.dart' ;
24import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
5+ import 'package:gsy_github_app_flutter/page/HomePage.dart' ;
6+ import 'package:gsy_github_app_flutter/page/LoginPage.dart' ;
37import 'package:gsy_github_app_flutter/page/WelcomePage.dart' ;
48import 'package:flutter_redux/flutter_redux.dart' ;
59import 'package:redux/redux.dart' ;
610
7- // One simple action: Increment
8- enum Actions { Increment }
9-
10- // The reducer, which takes the previous count and increments it in response
11- // to an Increment action.
12- int counterReducer (int state, dynamic action) {
13- if (action == Actions .Increment ) {
14- return state + 1 ;
15- }
16-
17- return state;
18- }
19-
2011
2112void main () {
22- final store = new Store <int >(counterReducer, initialState: 0 );
23-
24- runApp (new FlutterReduxApp (
25- title: 'Flutter Redux Demo' ,
26- store: store,
27- ));
13+ runApp (new FlutterReduxApp ());
2814}
2915
3016class FlutterReduxApp extends StatelessWidget {
31- final Store <int > store;
32- final String title;
3317
34- FlutterReduxApp ({Key key, this .store, this .title}) : super (key: key);
18+ final store = new Store <GSYState >(counterReducer, initialState: new GSYState (userInfo: User .empty ()));
19+
20+ FlutterReduxApp ({Key key}) : super (key: key);
3521
3622 @override
3723 Widget build (BuildContext context) {
38- return new StoreProvider < int > (
24+ return new StoreProvider (
3925 store: store,
40- child: new MaterialApp (
41- title: 'Flutter Demo' ,
42- theme: new ThemeData (
43- primarySwatch: GSYColors .primarySwatch,
44- ),
45- home: new WelcomePage ()),
26+ child: new MaterialApp (
27+ title: 'Flutter Demo' ,
28+ theme: new ThemeData (
29+ primarySwatch: GSYColors .primarySwatch,
30+ ),
31+ routes: {
32+ "/" : (context) {
33+ return WelcomePage ();
34+ },
35+ "home" : (context) {
36+ return HomePage ();
37+ },
38+ "login" : (context) {
39+ return LoginPage ();
40+ },
41+ }),
4642 );
4743 }
48- }
44+ }
0 commit comments