Просмотр исходного кода

rewrite according to lint rules

x1ongzhu 6 лет назад
Родитель
Сommit
01d9c6835f

+ 2 - 0
analysis_options.yaml

@@ -32,6 +32,8 @@ analyzer:
     # Stream and not importing dart:async
     # Please see https://github.com/flutter/flutter/pull/24528 for details.
     sdk_version_async_exported_from_core: ignore
+    avoid_void_async: error
+    always_declare_return_types: error
   exclude:
     - 'bin/cache/**'
     # the following two are relative to the stocks example and the flutter package respectively

+ 3 - 3
lib/pages/HomePage.dart

@@ -178,7 +178,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
     double width = MediaQuery.of(context).size.width;
     double height = MediaQuery.of(context).size.height;
     String endSTring = '';
-    if (seasonList.length > 0) {
+    if (seasonList.isNotEmpty) {
       int _time = seasonList[nowIndex].competitionSeason.endTime - DateTime.now().millisecondsSinceEpoch;
       _time = _time ~/ 1000 ~/ 3600 ~/ 24;
       endSTring = '倒计时 ' + _time.toString() + ' 天';
@@ -190,7 +190,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
           child: Stack(
             children: <Widget>[
               Container(
-                  child: seasonList.length > 0
+                  child: seasonList.isNotEmpty
                       ? Swiper(
                           index: nowIndex,
                           itemCount: seasonList.length,
@@ -303,7 +303,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
                     //   style: TextStyle(color: Colors.white, fontSize: 14),
                     // ),
                     Text(
-                      seasonList.length > 0 ? seasonList[nowIndex].gameName : '',
+                      seasonList.isNotEmpty ? seasonList[nowIndex].gameName : '',
                       style: TextStyle(color: Colors.white, fontSize: 14),
                     )
                   ],

+ 2 - 2
lib/pages/RecordList.dart

@@ -92,9 +92,9 @@ class RecordListState extends State<RecordList> {
               child: ListView.builder(
                   physics: AlwaysScrollableScrollPhysics(),
                   controller: _mControll,
-                  itemCount: playerList.length != 0 ? playerList.length : 1,
+                  itemCount: playerList.isNotEmpty ? playerList.length : 1,
                   itemBuilder: (BuildContext context, int index) {
-                    if (playerList.length == 0) {
+                    if (playerList.isEmpty) {
                       return Text(
                         '还没有战绩快去比赛吧...',
                         style: TextStyle(color: Colors.white30, fontSize: 13, height: 2),

+ 3 - 3
lib/pages/SecondRoomInfo.dart

@@ -23,7 +23,7 @@ class SecondPageState extends State<SecondPage> {
   ScrollController _perController;
 
   //获取房间用户
-  void getPlayerPage() async {
+  Future<void> getPlayerPage() async {
     ismore = false;
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.get('playerInfo/rankPage', data: {
@@ -93,7 +93,7 @@ class SecondPageState extends State<SecondPage> {
           itemCount: joinList.length + 1,
           itemBuilder: (BuildContext context, int index) {
             if (index < joinList.length) {
-              return person_item(joinList[index], index);
+              return PersonItem(joinList[index], index);
             } else {
               return Container(
                 padding: EdgeInsets.all(15),
@@ -108,7 +108,7 @@ class SecondPageState extends State<SecondPage> {
     );
   }
 
-  Widget person_item(PlayerInfo info, int index) {
+  Widget PersonItem(PlayerInfo info, int index) {
     return Container(
       width: double.infinity,
       height: 60,

+ 2 - 2
lib/pages/ShoppingMall.dart

@@ -67,7 +67,7 @@ class RechargeState extends State<Recharge> {
   int chooseMoney = 0;
   ProductInfo chooseProduct;
 
-  void getInfoList() async {
+  Future<void> getInfoList() async {
     Toast.show(context, '加载中', -1, 'loading');
     final Result res = await HttpManager.get('productInfo/all',
         data: {'typeFlag': widget.type});
@@ -80,7 +80,7 @@ class RechargeState extends State<Recharge> {
           productInfoList.add(product);
         });
       }
-      if (productInfoList.length > 0) {
+      if (productInfoList.isNotEmpty) {
         setState(() {
           chooseProduct = productInfoList[0];
         });

+ 1 - 2
lib/pages/TipInfo.dart

@@ -10,7 +10,6 @@ import '../model/HouseInfo.dart';
 import '../model/GameInfo.dart';
 import '../pages/RoomInfo.dart';
 import '../widget/SuccessfulReception.dart';
-import '../widget/CircleProgressBarPainter.dart';
 
 class TipInfo extends StatefulWidget {
   TipInfo({Key key, this.tipId}) : super(key: key);
@@ -23,7 +22,7 @@ class TipInfoState extends State<TipInfo> {
   SystemNotice tipInfo = SystemNotice.fromJson(
       {'content': '', 'createTime': DateTime.now().microsecondsSinceEpoch});
   HouseInfo houseInfo;
-  void getInfo() async {
+  Future<void> getInfo() async {
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.get('systemNotice/getOne',
         data: {'id': widget.tipId});

+ 2 - 2
lib/pages/TipList.dart

@@ -90,9 +90,9 @@ class TipListState extends State<TipList> {
                 child: ListView.builder(
                     physics: AlwaysScrollableScrollPhysics(),
                     controller: _mControll,
-                    itemCount: tipList.length != 0 ? tipList.length : 1,
+                    itemCount: tipList.isNotEmpty ? tipList.length : 1,
                     itemBuilder: (BuildContext context, int index) {
-                      if (tipList.length == 0) {
+                      if (tipList.isEmpty) {
                         return Text(
                           '数据正在火速加载中...',
                           style: TextStyle(color: Colors.white30, fontSize: 13, height: 2),

+ 3 - 3
lib/pages/UserChange.dart

@@ -174,7 +174,7 @@ class UserChangeState extends State<UserChange> {
     } else {}
   }
 
-  void _chooseSex(BuildContext context) async {
+  Future<void> _chooseSex(BuildContext context) async {
     String sex = await showCupertinoModalPopup(
         context: context,
         builder: (BuildContext context) {
@@ -207,7 +207,7 @@ class UserChangeState extends State<UserChange> {
     }
   }
 
-  void _chooseBirthday(BuildContext context) async {
+  Future<void> _chooseBirthday(BuildContext context) async {
     UserInfo userInfo = StoreProvider.of<AppState>(context).state.userInfo;
     DateTime date = userInfo.birthday > 0 ? DateTime.fromMillisecondsSinceEpoch(userInfo.birthday) : DateTime.now();
     DateTime res = await showCupertinoModalPopup<DateTime>(
@@ -327,7 +327,7 @@ class UserChangeState extends State<UserChange> {
 
   Widget _cell(String title, dynamic child, {String placeholder, void Function() onTap, bool showBorder = true}) {
     Widget secondChild;
-    if (child == null || (child is String && child.length == 0)) {
+    if (child == null || (child is String && child.isEmpty)) {
       secondChild = Text(
         placeholder ?? '',
         style: TextStyle(color: PLACEHOLDER_COLOR, fontSize: 13),

+ 4 - 2
lib/pages/openRoom.dart

@@ -36,7 +36,9 @@ class OpenRoomState extends State<OpenRoom> {
 
   Future<void> getFilePath() async {
     File file = await FilePicker.getFile(type: FileType.ANY);
-    if (file == null) return;
+    if (file == null) {
+      return;
+    }
     print(file.statSync());
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.post('assets/uploadFile', data: {
@@ -159,7 +161,7 @@ class OpenRoomState extends State<OpenRoom> {
       }
       setState(() {
         levelList = _list;
-        if (levelList.length > 0) {
+        if (levelList.isNotEmpty) {
           editRoomInfo['houseLevel'] = res2.data[0]['id'];
         }
       });

+ 2 - 2
lib/pages/rankList.dart

@@ -74,7 +74,7 @@ class RankListState extends State<RankList> {
       rankList = list;
     });
 
-    if (rankList.length == 0) {
+    if (rankList.isNotEmpty) {
       showBackDialog();
     }
   }
@@ -395,7 +395,7 @@ class RankListState extends State<RankList> {
 
   List<Widget> widgetList() {
     List<Widget> list = [];
-    if (rankList.length > 0) {
+    if (rankList.isNotEmpty) {
       list.add(Container(
         margin: EdgeInsets.only(top: 0, left: 30, right: 30),
         child: Stack(

+ 6 - 6
lib/pages/roomInfo.dart

@@ -77,7 +77,7 @@ class RoomInfoState extends State<RoomInfo>
   }
 
 //隔一秒检查是否开始
-  void getNowStatus() async {
+  Future<void> getNowStatus() async {
     Result res = await HttpManager.get('houseInfo/getPlayerNum',
         data: {'id': widget.roomId});
     if (res.success) {
@@ -95,7 +95,7 @@ class RoomInfoState extends State<RoomInfo>
   }
 
 //开始比赛确认按钮
-  void showStart() async {
+  Future<void> showStart() async {
     if (!isJoin) {
       return;
     }
@@ -177,7 +177,7 @@ class RoomInfoState extends State<RoomInfo>
     });
   }
 
-  void getEndTips() async {
+  Future<void> getEndTips() async {
     Result res = await HttpManager.get('playerInfo/endNum',
         data: {'houseId': widget.roomId});
 
@@ -207,7 +207,7 @@ class RoomInfoState extends State<RoomInfo>
   }
 
 //检查加入信息
-  void checkJoinInfo() async {
+  Future<void> checkJoinInfo() async {
     Result res = await HttpManager.get('playerInfo/getOne', data: {
       'userId': StoreProvider.of<AppState>(context).state.userInfo.id,
       'houseId': widget.roomId
@@ -293,7 +293,7 @@ class RoomInfoState extends State<RoomInfo>
   }
 
 //加入房间
-  void joinRoom() async {
+  Future<void> joinRoom() async {
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.post('houseInfo/join', data: {
       'houseId': widget.roomId,
@@ -990,7 +990,7 @@ class RankContent extends StatefulWidget {
 
 class RankContentState extends State<RankContent> {
   List<PlayerInfo> topList = [];
-  void getTopList() async {
+  Future<void> getTopList() async {
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.get('playerInfo/rankPage',
         data: {'houseId': widget.roomId, 'currentPage': 1, 'pageNumber': 3});

+ 2 - 2
lib/pages/roomList.dart

@@ -66,7 +66,7 @@ class RoomListState extends State<RoomList> {
     });
   }
 
-  void getInfo() async {
+  Future<void> getInfo() async {
     Result res = await HttpManager.get('gameInfo/all');
     if (res.success) {
       setState(() {
@@ -125,7 +125,7 @@ class RoomListState extends State<RoomList> {
                     SliverFixedExtentList(
                       itemExtent: ScreenUtil().setWidth(78),
                       delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
-                        if(roomList.length==0){
+                        if(roomList.isEmpty){
                           return Text('暂无数据',style: TextStyle(
                             color: Colors.grey,
                             fontSize: 13,

+ 3 - 3
lib/pages/setting.dart

@@ -156,7 +156,7 @@ class SettingState extends State<Setting> {
     } else {}
   }
 
-  void _chooseSex(BuildContext context) async {
+    Future<void> _chooseSex(BuildContext context) async {
     String sex = await showCupertinoModalPopup(
         context: context,
         builder: (BuildContext context) {
@@ -190,7 +190,7 @@ class SettingState extends State<Setting> {
     }
   }
 
-  void _chooseBirthday(BuildContext context) async {
+  Future<void> _chooseBirthday(BuildContext context) async {
     UserInfo userInfo = StoreProvider.of<AppState>(context).state.userInfo;
     DateTime date = userInfo.birthday > 0 ? DateTime.fromMillisecondsSinceEpoch(userInfo.birthday) : DateTime.now();
     DateTime res = await showCupertinoModalPopup<DateTime>(
@@ -284,7 +284,7 @@ class SettingState extends State<Setting> {
 
   Widget _cell(String title, dynamic child, {String placeholder, void Function() onTap, bool showBorder = true}) {
     Widget secondChild;
-    if (child == null || (child is String && child.length == 0)) {
+    if (child == null || (child is String && child.isEmpty)) {
       secondChild = Text(
         placeholder ?? '',
         style: TextStyle(color: PLACEHOLDER_COLOR, fontSize: 13),

+ 9 - 32
lib/widget/HomeDrawer.dart

@@ -21,8 +21,7 @@ class HomeDrawerState extends State<HomeDrawer> {
   Future<void> getUserInfo() async {
     Result res = await HttpManager.get('userInfo/getUserInfo');
     if (res.success) {
-      StoreProvider.of<AppState>(context)
-          .dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
+      StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
     } else {}
   }
 
@@ -62,10 +61,7 @@ class HomeDrawerState extends State<HomeDrawer> {
                             fit: BoxFit.cover,
                           ),
                           onTap: () {
-                            Navigator.push(
-                                context,
-                                CupertinoPageRoute(
-                                    builder: (context) => UserChange()));
+                            Navigator.push(context, CupertinoPageRoute(builder: (context) => UserChange()));
                           },
                         ),
                       ),
@@ -77,10 +73,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,
@@ -90,16 +83,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),
                                 )
                               ],
                             ),
@@ -120,28 +109,19 @@ class HomeDrawerState extends State<HomeDrawer> {
                         'images/icon_qianbao.png',
                         '我的钱包',
                         onTap: () {
-                          Navigator.push(
-                              context,
-                              CupertinoPageRoute(
-                                  builder: (context) => MyWallet()));
+                          Navigator.push(context, CupertinoPageRoute(builder: (context) => MyWallet()));
                         },
                       ),
                       Divder(),
                       DrawerMenu('images/icon_zhanji.png', '我的战绩', onTap: () {
-                        Navigator.push(
-                            context,
-                            CupertinoPageRoute(
-                                builder: (context) => RecordList()));
+                        Navigator.push(context, CupertinoPageRoute(builder: (context) => RecordList()));
                       }),
                       Divder(),
                       DrawerMenu(
                         'images/icon_bangding.png',
                         '游戏绑定',
                         onTap: () {
-                          Navigator.push(
-                              context,
-                              CupertinoPageRoute(
-                                  builder: (context) => BindGame()));
+                          Navigator.push(context, CupertinoPageRoute(builder: (context) => BindGame()));
                         },
                       ),
                       // Divder(),
@@ -196,10 +176,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),
                 ),
               ),
             ),

+ 3 - 3
lib/widget/ITextInput.dart

@@ -24,7 +24,7 @@ class ITextField extends StatefulWidget {
 
   ITextField(
       {Key key,
-      ITextInputType keyboardType: ITextInputType.text,
+      ITextInputType keyboardType = ITextInputType.text,
       this.maxLines = 1,
       this.maxLength,
       this.hintText,
@@ -109,8 +109,8 @@ class _ITextFieldState extends State<ITextField> {
 
   @override
   Widget build(BuildContext context) {
-    TextEditingController _controller = TextEditingController.fromValue(TextEditingValue(
-        text: _inputText, selection: TextSelection.fromPosition(TextPosition(affinity: TextAffinity.downstream, offset: _inputText.length))));
+    TextEditingController _controller = TextEditingController.fromValue(
+        TextEditingValue(text: _inputText, selection: TextSelection.fromPosition(TextPosition(affinity: TextAffinity.downstream, offset: _inputText.length))));
     TextField textField = TextField(
       autofocus: widget.autofocus,
       focusNode: _focusNode,

+ 2 - 2
lib/widget/LocalVideoPlayer.dart

@@ -9,7 +9,7 @@ class LocalVideoPlayer extends StatefulWidget {
   final String source;
   bool isFullScreen;
 
-  LocalVideoPlayer(this.source, {this.isFullScreen: false});
+  LocalVideoPlayer(this.source, {this.isFullScreen = false});
 
   @override
   _LocalVideoPlayerState createState() => _LocalVideoPlayerState();
@@ -76,7 +76,7 @@ class PlayView extends StatefulWidget {
   VideoPlayerController controller;
   bool allowFullScreen;
 
-  PlayView(this.controller, {this.allowFullScreen: true});
+  PlayView(this.controller, {this.allowFullScreen = true});
 
   @override
   _PlayViewState createState() => _PlayViewState();