x1ongzhu 6 yıl önce
ebeveyn
işleme
4dbb0f4b57

+ 5 - 0
android/app/build.gradle

@@ -41,6 +41,11 @@ android {
         ndk {
             // abiFilters 'armeabi-v7a'
         }
+        manifestPlaceholders = [
+            JPUSH_PKGNAME : applicationId,
+            JPUSH_APPKEY : "868cc9036e14c71e2b698f46",
+            JPUSH_CHANNEL : "developer-default",
+        ]
     }
     signingConfigs {
         debug {

+ 10 - 7
lib/main.dart

@@ -1,10 +1,10 @@
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/services.dart';
+import 'package:jpush_flutter/jpush_flutter.dart';
 import 'package:redux/redux.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_redux/flutter_redux.dart';
 import 'package:shared_preferences/shared_preferences.dart';
-import 'package:url_launcher/url_launcher.dart';
 import 'redux/AppState.dart';
 import 'pages/HomePage.dart';
 import 'net/HttpManager.dart';
@@ -50,7 +50,7 @@ class MobileCyberGamesApp extends StatelessWidget {
               highlightColor: Color(0xFF9B4040),
               splashColor: Color(0xFF9B4040),
             )),
-        home: store.state.isLogin ? HomePage() : LoginFirst(),
+        home: store.state.userInfo != null ? HomePage() : LoginFirst(),
       ),
     );
   }
@@ -61,19 +61,22 @@ void main() async {
     statusBarColor: Colors.transparent,
   ));
   await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
+  JPush jpush = new JPush();
+  jpush.setup(
+    appKey: "868cc9036e14c71e2b698f46",
+    channel: "theChannel",
+    production: false,
+    debug: true,
+  );
+  jpush.applyPushAuthority(new NotificationSettingsIOS(sound: true, alert: true, badge: true));
   final prefs = await SharedPreferences.getInstance();
   print(prefs.getString('token'));
-  //测试token
-  // HttpManager.token=prefs.getString('token')??"eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIyZDExNzgzOS1lZTQxLTRmZjItOGMyYi0zMzdiNmVhYWE3ODUiLCJpc3MiOiJhZG1pbiIsImlhdCI6MTU1MTMzNjAxNiwic3ViIjoiODQ3MDIiLCJleHAiOjE1NTE1OTUyMTZ9.VFvZRMpAvrPos5FwgkaofVemgb5rAXVuGTOSiHcNEKw";
   HttpManager.token = prefs.getString('token') ?? "";
   Result result = await HttpManager.get("userInfo/getUserInfo");
   AppState state = AppState.empty();
   if (result.success && result.data != null) {
-    state.isLogin = true;
     UserInfo userInfo = UserInfo.fromJson(result.data);
     state.userInfo = userInfo;
-  } else {
-    state.isLogin = false;
   }
   Store<AppState> store = Store<AppState>(appReducer, initialState: state);
   runApp(new MobileCyberGamesApp(store));

+ 17 - 81
lib/pages/HomePage.dart

@@ -1,5 +1,4 @@
 import 'package:flutter/material.dart';
-import 'package:flutter_redux/flutter_redux.dart';
 import '../widget/HomeDrawer.dart';
 import './Setting.dart';
 import './CreateRoom.dart';
@@ -8,14 +7,11 @@ import 'rankList.dart';
 import 'roomInfo.dart'; //房间信息
 import 'package:flutter/cupertino.dart';
 import 'package:flutter_swiper/flutter_swiper.dart';
-import 'package:flutter_screenutil/flutter_screenutil.dart';
 import '../model/CompetitionSeason.dart';
 import '../styles/totast.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
 import 'TipList.dart';
-import '../model/UserInfo.dart';
-import '../redux/AppState.dart';
 
 class HomePage extends StatefulWidget {
   @override
@@ -70,16 +66,11 @@ class _HomePageState extends State<HomePage> {
 
   void getOneRoom() async {
     Toast.show(context, '加载中', -1, 'loading');
-    Result res =
-        await HttpManager.get("houseInfo/getOne", data: {'statusFlag': 0});
+    Result res = await HttpManager.get("houseInfo/getOne", data: {'statusFlag': 0});
     Toast.hide();
     if (res.success) {
       if (res.data != null) {
-        Navigator.push(
-            context,
-            new CupertinoPageRoute(
-                builder: (context) =>
-                    new RoomInfo(roomId: res.data['id'].toString())));
+        Navigator.push(context, new CupertinoPageRoute(builder: (context) => new RoomInfo(roomId: res.data['id'].toString())));
       } else {
         showBackDialog();
       }
@@ -89,24 +80,21 @@ class _HomePageState extends State<HomePage> {
   @override
   void initState() {
     super.initState();
-    Future.delayed(const Duration(seconds: 1), () {
+    Future.delayed(Duration.zero, () {
       getSeasonInfo();
     });
   }
 
   @override
   Widget build(BuildContext context) {
-    ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
     return Scaffold(
       drawer: HomeDrawer(),
       body: Container(
         width: double.infinity,
         height: double.infinity,
         decoration: BoxDecoration(
-            gradient: LinearGradient(colors: [
-          Color.fromARGB(255, 177, 59, 56),
-          Color.fromARGB(255, 147, 64, 61)
-        ], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
+            gradient: LinearGradient(
+                colors: [Color.fromARGB(255, 177, 59, 56), Color.fromARGB(255, 147, 64, 61)], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
         child: SafeArea(
           child: centerWidget(context),
         ),
@@ -115,7 +103,6 @@ class _HomePageState extends State<HomePage> {
   }
 
   Widget centerWidget(BuildContext context) {
-    UserInfo userInfo = StoreProvider.of<AppState>(context).state.userInfo;
     return Column(
       children: <Widget>[
         Expanded(
@@ -129,11 +116,7 @@ class _HomePageState extends State<HomePage> {
                           scrollDirection: Axis.horizontal,
                           loop: true,
                           onTap: (index) {
-                            Navigator.push(
-                                context,
-                                new CupertinoPageRoute(
-                                    builder: (context) => new RankList(
-                                        raceId: seasonList[index].id)));
+                            Navigator.push(context, new CupertinoPageRoute(builder: (context) => new RankList(raceId: seasonList[index].id)));
                           },
                           onIndexChanged: (index) {
                             setState(() {
@@ -150,15 +133,12 @@ class _HomePageState extends State<HomePage> {
                                       Image.asset("images/home_icon_yuan.png"),
                                       Center(
                                         child: Row(
-                                          mainAxisAlignment:
-                                              MainAxisAlignment.center,
-                                          crossAxisAlignment:
-                                              CrossAxisAlignment.baseline,
+                                          mainAxisAlignment: MainAxisAlignment.center,
+                                          crossAxisAlignment: CrossAxisAlignment.baseline,
                                           textBaseline: TextBaseline.alphabetic,
                                           children: <Widget>[
                                             Text(
-                                              (seasonList[index].bonus / 1000)
-                                                  .toStringAsFixed(1),
+                                              (seasonList[index].bonus / 1000).toStringAsFixed(1),
                                               style: TextStyle(
                                                 color: Colors.white,
                                                 fontSize: 68,
@@ -230,10 +210,7 @@ class _HomePageState extends State<HomePage> {
                   color: Colors.transparent,
                   child: InkWell(
                     onTap: () {
-                      Navigator.push(
-                          context,
-                          new CupertinoPageRoute(
-                              builder: (context) => new Setting()));
+                      Navigator.push(context, new CupertinoPageRoute(builder: (context) => new Setting()));
                     },
                     child: Padding(
                       padding: EdgeInsets.all(12),
@@ -255,40 +232,12 @@ class _HomePageState extends State<HomePage> {
                       style: TextStyle(color: Colors.white, fontSize: 14),
                     ),
                     Text(
-                      seasonList.length > 0
-                          ? seasonList[nowIndex].gameInfo.gameName
-                          : '',
+                      seasonList.length > 0 ? seasonList[nowIndex].gameInfo.gameName : '',
                       style: TextStyle(color: Colors.white, fontSize: 14),
                     )
                   ],
                 ),
               ),
-              // Positioned(
-              //   bottom: 60,
-              //   left: 0,
-              //   child: FlatButton(
-              //     child: Text("stream"),
-              //     onPressed: () async {
-              //       bool success = await ScreenStreamPlugin.start(
-              //           'rtmp://49.4.66.233:1935/myapp/' +
-              //               userInfo.id.toString() +
-              //               '?playerInfoId=' +
-              //               '1234');
-              //       print('stream screen:' + success.toString());
-              //     },
-              //   ),
-              // ),
-              // Positioned(
-              //   bottom: 60,
-              //   right: 0,
-              //   child: FlatButton(
-              //     child: Text("stop stream"),
-              //     onPressed: () async {
-              //       bool success = await ScreenStreamPlugin.stop();
-              //       print('stop stream screen:' + success.toString());
-              //     },
-              //   ),
-              // )
             ],
           ),
         ),
@@ -305,13 +254,9 @@ class _HomePageState extends State<HomePage> {
                   Navigator.of(context).push(PageRouteBuilder(
                       opaque: false,
                       transitionDuration: Duration(milliseconds: 300),
-                      transitionsBuilder: (BuildContext context,
-                          Animation<double> animation,
-                          Animation<double> secondaryAnimation,
-                          Widget child) {
+                      transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
                         return FadeTransition(
-                          opacity: CurvedAnimation(
-                              parent: animation, curve: Curves.linear),
+                          opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
                           child: child,
                         );
                       },
@@ -331,20 +276,14 @@ class _HomePageState extends State<HomePage> {
                 "images/home_icon_sousuo.png",
                 "搜索",
                 onTapHomeMenu: () {
-                  Navigator.push(
-                      context,
-                      new CupertinoPageRoute(
-                          builder: (context) => new RoomList()));
+                  Navigator.push(context, new CupertinoPageRoute(builder: (context) => new RoomList()));
                 },
               ),
               HomeMenu(
                 "images/home_icon_youjian.png",
                 "邮件",
                 onTapHomeMenu: () {
-                  Navigator.push(
-                      context,
-                      new CupertinoPageRoute(
-                          builder: (context) => new TipList()));
+                  Navigator.push(context, new CupertinoPageRoute(builder: (context) => new TipList()));
                 },
               ),
             ],
@@ -365,11 +304,8 @@ class HomeMenu extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Container(
-      decoration: BoxDecoration(
-          gradient: LinearGradient(
-              begin: Alignment.topCenter,
-              end: Alignment.bottomCenter,
-              colors: [Color(0xFF626C85), Color(0xFF3D3E6C)])),
+      decoration:
+          BoxDecoration(gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [Color(0xFF626C85), Color(0xFF3D3E6C)])),
       child: AspectRatio(
         aspectRatio: 1,
         child: Container(

+ 32 - 48
lib/pages/changeUserInfo.dart

@@ -9,7 +9,7 @@ import '../redux/AppState.dart';
 import '../model/UserInfo.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
-import 'dart:convert';
+import '../redux/UserRedux.dart';
 
 class ChangeUserInfo extends StatefulWidget {
   ChangeUserInfo({Key key, this.title, this.val}) : super(key: key);
@@ -66,17 +66,13 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
                               fontSize: 16,
                               color: Color(0xFF727785),
                             ),
-                            textStyle: TextStyle(
-                                color: Colors.white,
-                                fontSize: 18,
-                                fontWeight: FontWeight.w500),
+                            textStyle: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500),
                             fieldCallBack: (content) {
                               setState(() {
                                 changeText = content;
                               });
                             },
-                            counterStyle:
-                                TextStyle(color: BG_SUB_COLOR, fontSize: 0),
+                            counterStyle: TextStyle(color: BG_SUB_COLOR, fontSize: 0),
                           ),
                         ),
                         Container(
@@ -84,47 +80,35 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
                           width: double.infinity,
                           height: 48,
                           child: FlatButton(
-                              textColor: Colors.white,
-                              color: PRIMARY_COLOR,
-                              highlightColor: Color(0xFF763434),
-                              child: Text(
-                                "确定修改",
-                                style: TextStyle(
-                                    fontSize: 16, fontWeight: FontWeight.w500),
-                              ),
-                              onPressed: () async {
-                                if (changeText.isEmpty) {
-                                  Toast.show(context, '修改内容不能为空', 1500, 'info');
-                                  return;
-                                }
-                                Toast.show(context, '加载中', -1, 'loading');
-                                final Result res = await HttpManager.post(
-                                    'userInfo/update',
-                                    data: {
-                                      "id": userInfo.id,
-                                      changekey: changeText
-                                    });
-                                Toast.hide();
-                                if (res.success) {
-                                  Result res2 = await HttpManager.get(
-                                      "userInfo/getUserInfo");
-                                  if (res2.success) {
-                                    StoreProvider.of<AppState>(context)
-                                        .dispatch({
-                                      "action": Actions.updateUser,
-                                      "user": res2.data
-                                    });
-                                    Toast.show(
-                                        context, '修改成功', 1000, 'success');
-                                    Future.delayed(Duration(milliseconds: 1000),
-                                        () {
-                                      Navigator.of(context).pop();
-                                    });
-                                  } else {}
-                                } else {
-                                  Toast.show(context, res.error, 1500, 'info');
-                                }
-                              }),
+                            textColor: Colors.white,
+                            color: PRIMARY_COLOR,
+                            highlightColor: Color(0xFF763434),
+                            child: Text(
+                              "确定修改",
+                              style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
+                            ),
+                            onPressed: () async {
+                              if (changeText.isEmpty) {
+                                Toast.show(context, '修改内容不能为空', 1500, 'info');
+                                return;
+                              }
+                              Toast.show(context, '加载中', -1, 'loading');
+                              final Result res = await HttpManager.post('userInfo/update', data: {"id": userInfo.id, changekey: changeText});
+                              Toast.hide();
+                              if (res.success) {
+                                Result res2 = await HttpManager.get("userInfo/getUserInfo");
+                                if (res2.success) {
+                                  StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res2.data)));
+                                  Toast.show(context, '修改成功', 1000, 'success');
+                                  Future.delayed(Duration(milliseconds: 1000), () {
+                                    Navigator.of(context).pop();
+                                  });
+                                } else {}
+                              } else {
+                                Toast.show(context, res.error, 1500, 'info');
+                              }
+                            },
+                          ),
                         ),
                       ],
                     ),

+ 38 - 35
lib/pages/loginSecond.dart

@@ -10,6 +10,8 @@ import '../net/HttpManager.dart';
 import '../net/Result.dart';
 import 'HomePage.dart';
 import '../redux/AppState.dart';
+import '../redux/UserRedux.dart';
+import '../model/UserInfo.dart';
 
 class LoginSecond extends StatefulWidget {
   LoginSecond({Key key, this.phone}) : super(key: key);
@@ -107,43 +109,44 @@ class LoginSecondState extends State<LoginSecond> {
                               ),
                             ),
                             Container(
-                                margin: EdgeInsets.only(top: 63, bottom: 20),
-                                width: double.infinity,
-                                height: 48,
-                                child: FlatButton(
-                                  textColor: Colors.white,
-                                  color: PRIMARY_COLOR,
-                                  highlightColor: Color(0xFF763434),
-                                  child: Text("注册/登录"),
-                                  onPressed: () async {
-                                    if (_sessionID == null) {
-                                      Toast.show(context, '请发送验证码', 1500, 'info');
-                                    } else if (inputCode.length != 6) {
-                                      Toast.show(context, '请输入验证码', 1500, 'info');
+                              margin: EdgeInsets.only(top: 63, bottom: 20),
+                              width: double.infinity,
+                              height: 48,
+                              child: FlatButton(
+                                textColor: Colors.white,
+                                color: PRIMARY_COLOR,
+                                highlightColor: Color(0xFF763434),
+                                child: Text("注册/登录"),
+                                onPressed: () async {
+                                  if (_sessionID == null) {
+                                    Toast.show(context, '请发送验证码', 1500, 'info');
+                                  } else if (inputCode.length != 6) {
+                                    Toast.show(context, '请输入验证码', 1500, 'info');
+                                  } else {
+                                    Toast.show(context, '加载中', -1, 'loading');
+                                    final Result res = await HttpManager.post('auth/loginSms',
+                                        data: {"phone": widget.phone, "code": inputCode, "sessionId": _sessionID, "requireToken": true});
+                                    Toast.hide();
+                                    if (res.success) {
+                                      final prefs = await SharedPreferences.getInstance();
+                                      await prefs.setString('token', res.token);
+                                      HttpManager.token = res.token;
+                                      StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
+
+                                      Toast.show(context, '登录成功', 1500, 'success');
+                                      Navigator.pushAndRemoveUntil(
+                                          context,
+                                          new CupertinoPageRoute(
+                                            builder: (context) => new HomePage(),
+                                          ),
+                                          ModalRoute.withName('/'));
                                     } else {
-                                      Toast.show(context, '加载中', -1, 'loading');
-                                      final Result res = await HttpManager.post('auth/loginSms',
-                                          data: {"phone": widget.phone, "code": inputCode, "sessionId": _sessionID, "requireToken": true});
-                                      Toast.hide();
-                                      if (res.success) {
-                                        final prefs = await SharedPreferences.getInstance();
-                                        await prefs.setString('token', res.token);
-                                        print(prefs.getString('token'));
-                                        HttpManager.token = res.token;
-                                        StoreProvider.of<AppState>(context).dispatch({"action": Actions.updateAll, "user": res.data});
-                                        Toast.show(context, '登录成功', 1500, 'success');
-                                        Navigator.pushAndRemoveUntil(
-                                            context,
-                                            new CupertinoPageRoute(
-                                              builder: (context) => new HomePage(),
-                                            ),
-                                            ModalRoute.withName('/'));
-                                      } else {
-                                        Toast.show(context, res.error, 1500, 'info');
-                                      }
+                                      Toast.show(context, res.error, 1500, 'info');
                                     }
-                                  },
-                                ))
+                                  }
+                                },
+                              ),
+                            )
                           ],
                         ),
                       ),

+ 3 - 2
lib/pages/setting.dart

@@ -20,6 +20,7 @@ import '../redux/AppState.dart';
 import '../model/UserInfo.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
+import '../redux/UserRedux.dart';
 
 class Setting extends StatefulWidget {
   @override
@@ -153,7 +154,7 @@ class SettingState extends State<Setting> {
                           ),
                           onPressed: () {
                             Future.delayed(const Duration(seconds: 1), () {
-                              StoreProvider.of<AppState>(context).dispatch({"action": Actions.logout});
+                              StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(null));
                             });
 
                             Toast.show(context, '退出成功', 1500, 'success');
@@ -191,7 +192,7 @@ class SettingState extends State<Setting> {
   void getUserInfo() async {
     Result res = await HttpManager.get("userInfo/getUserInfo");
     if (res.success) {
-      StoreProvider.of<AppState>(context).dispatch({"action": Actions.updateUser, "user": res.data});
+      StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
     } else {}
   }
 

+ 3 - 17
lib/redux/AppState.dart

@@ -1,30 +1,16 @@
 import '../model/UserInfo.dart';
+import 'UserRedux.dart';
 
 enum Actions { updateToken, updateUser, updateAll, logout }
 
 class AppState {
-  bool isLogin = false;
   UserInfo userInfo;
 
-  AppState(this.isLogin, this.userInfo);
+  AppState({this.userInfo});
 
   AppState.empty();
 }
 
 AppState appReducer(AppState state, action) {
-  print(action);
-  if (Actions.updateAll == action['action']) {
-    state.userInfo = UserInfo.fromJson(action['user']);
-    state.isLogin = true;
-    return state;
-  } else if (Actions.updateUser == action['action']) {
-    state.userInfo = UserInfo.fromJson(action['user']);
-    return state;
-  } else if (Actions.logout == action['action']) {
-    state.userInfo = null;
-    state.isLogin = false;
-    return state;
-  } else {
-    return AppState.empty();
-  }
+  return AppState(userInfo: userReducer(state.userInfo, action));
 }

+ 41 - 0
lib/redux/UserRedux.dart

@@ -0,0 +1,41 @@
+import 'package:jpush_flutter/jpush_flutter.dart';
+
+import '../model/UserInfo.dart';
+import 'package:redux/redux.dart';
+
+/**
+ * 用户相关Redux
+ * Created by guoshuyu
+ * Date: 2018-07-16
+ */
+/// redux 的 combineReducers, 通过 TypedReducer 将 UpdateUserAction 与 reducers 关联起来
+final userReducer = combineReducers<UserInfo>([
+  TypedReducer<UserInfo, UpdateUserAction>(_updateLoaded),
+]);
+
+/// 如果有 UpdateUserAction 发起一个请求时
+/// 就会调用到 _updateLoaded
+/// _updateLoaded 这里接受一个新的userInfo,并返回
+UserInfo _updateLoaded(UserInfo userInfo, action) {
+  JPush jpush = JPush();
+  if (action.userInfo != null) {
+    if (userInfo.id != action.userInfo.id) {
+      jpush.setAlias(action.userInfo.id.toString()).then((map) {});
+    }
+  } else {
+    jpush.deleteAlias();
+  }
+  userInfo = action.userInfo;
+  return userInfo;
+}
+
+///定一个 UpdateUserAction ,用于发起 userInfo 的的改变
+///类名随你喜欢定义,只要通过上面TypedReducer绑定就好
+class UpdateUserAction {
+  final UserInfo userInfo;
+  UpdateUserAction(this.userInfo);
+}
+
+class LogoutAction {
+  LogoutAction();
+}

+ 16 - 36
lib/widget/HomeDrawer.dart

@@ -4,13 +4,12 @@ import 'package:flutter_redux/flutter_redux.dart';
 import 'package:flutter/cupertino.dart';
 import '../redux/AppState.dart';
 import '../model/UserInfo.dart';
-import '../pages/MyWallet.dart'; //我的钱包
-import '../pages/BindGame.dart'; //游戏绑定
-import '../pages/RecordList.dart'; //我的战绩
+import '../pages/MyWallet.dart';
+import '../pages/BindGame.dart';
+import '../pages/RecordList.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
-import '../model/UserInfo.dart';
-import '../redux/AppState.dart';
+import '../redux/UserRedux.dart';
 
 class HomeDrawer extends StatefulWidget {
   @override
@@ -18,19 +17,19 @@ class HomeDrawer extends StatefulWidget {
 }
 
 class HomeDrawerState extends State<HomeDrawer> {
-
-   void getUserInfo() async {
+  void getUserInfo() async {
     Result res = await HttpManager.get("userInfo/getUserInfo");
     if (res.success) {
-      StoreProvider.of<AppState>(context).dispatch({"action": Actions.updateUser, "user": res.data});
+      StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
     } else {}
   }
+
   @override
   void initState() {
-    // TODO: implement initState
     super.initState();
-    Future.delayed(Duration(milliseconds: 100),()=>getUserInfo);
+    Future.delayed(Duration(milliseconds: 100), () => getUserInfo);
   }
+
   @override
   Widget build(BuildContext context) {
     return StoreConnector<AppState, UserInfo>(
@@ -68,10 +67,7 @@ class HomeDrawerState extends State<HomeDrawer> {
                           children: <Widget>[
                             Text(
                               userInfo.nickname,
-                              style: TextStyle(
-                                  fontSize: 27,
-                                  color: Colors.white,
-                                  fontWeight: FontWeight.w700),
+                              style: TextStyle(fontSize: 27, color: Colors.white, fontWeight: FontWeight.w700),
                             ),
                             Row(
                               mainAxisAlignment: MainAxisAlignment.center,
@@ -81,16 +77,12 @@ class HomeDrawerState extends State<HomeDrawer> {
                                   child: SizedBox(
                                     width: 20,
                                     height: 20,
-                                    child: Image.asset(
-                                        "images/icon_jinbi_da_bai.png"),
+                                    child: Image.asset("images/icon_jinbi_da_bai.png"),
                                   ),
                                 ),
                                 Text(
                                   userInfo.moneyCoin.toString(),
-                                  style: TextStyle(
-                                      fontSize: 16,
-                                      color: Colors.white,
-                                      fontWeight: FontWeight.w700),
+                                  style: TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.w700),
                                 )
                               ],
                             ),
@@ -111,28 +103,19 @@ class HomeDrawerState extends State<HomeDrawer> {
                         "images/icon_qianbao.png",
                         "我的钱包",
                         onTap: () {
-                          Navigator.push(
-                              context,
-                              new CupertinoPageRoute(
-                                  builder: (context) => new MyWallet()));
+                          Navigator.push(context, new CupertinoPageRoute(builder: (context) => new MyWallet()));
                         },
                       ),
                       Divder(),
                       DrawerMenu("images/icon_zhanji.png", "我的战绩", onTap: () {
-                        Navigator.push(
-                            context,
-                            new CupertinoPageRoute(
-                                builder: (context) => new RecordList()));
+                        Navigator.push(context, new CupertinoPageRoute(builder: (context) => new RecordList()));
                       }),
                       Divder(),
                       DrawerMenu(
                         "images/icon_bangding.png",
                         "游戏绑定",
                         onTap: () {
-                          Navigator.push(
-                              context,
-                              new CupertinoPageRoute(
-                                  builder: (context) => new BindGame()));
+                          Navigator.push(context, new CupertinoPageRoute(builder: (context) => new BindGame()));
                         },
                       )
                     ],
@@ -183,10 +166,7 @@ class DrawerMenu extends StatelessWidget {
                 margin: EdgeInsets.only(left: 16),
                 child: Text(
                   title,
-                  style: TextStyle(
-                      color: Colors.white,
-                      fontSize: 15,
-                      fontWeight: FontWeight.w700),
+                  style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w700),
                 ),
               ),
             ),

+ 1 - 0
pubspec.yaml

@@ -31,6 +31,7 @@ dependencies:
   package_info: ^0.4.0
   video_player: ^0.10.0
   url_launcher: ^5.0.1
+  jpush_flutter: ^0.0.11
 
 dev_dependencies:
   build_runner: ^1.1.1