Browse Source

修复代码提示的警告

liuyuqi-dellpc 3 years ago
parent
commit
a6b6d6b6a5
3 changed files with 9 additions and 16 deletions
  1. 4 4
      lib/store/game_state.dart
  2. 4 9
      lib/views/mode_selector.dart
  3. 1 3
      lib/views/scores.dart

+ 4 - 4
lib/store/game_state.dart

@@ -21,10 +21,10 @@ class GameState {
       block2 = random.nextInt(gamesize);
     }
 
-    var newdata = List<List<BlockInfo>>();
+    var newdata = <List<BlockInfo>>[];
 
     for (var i = 0; i < mode; i++) {
-      var row = List<BlockInfo>();
+      var row = <BlockInfo>[];
       for (var j = 0; j < mode; j++) {
         var current = i * mode + j;
         row.add(BlockInfo(
@@ -129,9 +129,9 @@ class GameState {
   }
 
   GameState clone() {
-    var newdata = List<List<BlockInfo>>();
+    var newdata = <List<BlockInfo>>[];
     for (var i = 0; i < mode; i++) {
-      var row = List<BlockInfo>();
+      var row = <BlockInfo>[];
       for (var j = 0; j < mode; j++) {
         row.add(BlockInfo(
           current: data[i][j].current,

+ 4 - 9
lib/views/mode_selector.dart

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter_2048/service/gameInit.dart';
 import 'package:flutter_redux/flutter_redux.dart';
 import '../store/game_state.dart';
+
 // 选择模式界面
 class ModeSelector extends StatelessWidget {
   @override
@@ -18,21 +19,15 @@ class ModeSelector extends StatelessWidget {
           child: Row(
             mainAxisAlignment: MainAxisAlignment.spaceBetween,
             children: <Widget>[
-              FlatButton(
-                color: Color(0xff8f7a66),
-                textColor: Colors.white,
+              TextButton(
                 onPressed: () => vm.onChange(3),
                 child: Text('3 x 3'),
               ),
-              FlatButton(
-                color: Color(0xff8f7a66),
-                textColor: Colors.white,
+              TextButton(
                 onPressed: () => vm.onChange(4),
                 child: Text('4 x 4'),
               ),
-              FlatButton(
-                color: Color(0xff8f7a66),
-                textColor: Colors.white,
+              TextButton(
                 onPressed: () => vm.onChange(6),
                 child: Text('6 x 6'),
               ),

+ 1 - 3
lib/views/scores.dart

@@ -111,9 +111,7 @@ class Scores extends StatelessWidget {
                     ),
                   ],
                 ),
-                FlatButton(
-                  color: Color(0xff8f7a66),
-                  textColor: Colors.white,
+                TextButton(
                   onPressed: () => props.reset(),
                   child: Text(
                     S.of(context).btnNewGame,