Browse Source

update to sdk: ">=2.17.6 <3.0.0"

git@h5.yoqi.me 1 year ago
parent
commit
80d7b18057

+ 5 - 1
lib/model/block_info.dart

@@ -1,5 +1,9 @@
 class BlockInfo {
-  BlockInfo({this.value, this.current, this.before, this.myis = true}) {
+  BlockInfo(
+      {required this.value,
+      required this.current,
+      this.before,
+      this.myis = true}) {
     this.before = this.before == null ? this.current : this.before;
   }
 

+ 4 - 4
lib/model/game_status.dart

@@ -1,11 +1,11 @@
 /// 当前状态
 class GameStatus {
   GameStatus({
-    this.adds,
+    required this.adds,
     this.moves,
-    this.scores,
-    this.total,
-    this.end,
+    required this.scores,
+    required this.total,
+    required this.end,
   });
 
   int scores;

+ 2 - 3
lib/pages/index_page.dart

@@ -16,7 +16,6 @@ import '../store/game_state.dart';
 
 /// 首页
 class IndexPage extends StatelessWidget {
-
   @override
   Widget build(BuildContext context) {
     //ScreenUtil 初始化实例
@@ -25,7 +24,7 @@ class IndexPage extends StatelessWidget {
             maxWidth: MediaQuery.of(context).size.width,
             maxHeight: MediaQuery.of(context).size.height),
         designSize: Size(360, 640),
-        orientation: Orientation.portrait);  // 竖屏
+        orientation: Orientation.portrait); // 竖屏
 
     return StoreProvider(
       store: Store<GameState>(
@@ -69,5 +68,5 @@ class IndexPage extends StatelessWidget {
 class GameProps {
   bool started;
 
-  GameProps({this.started});
+  GameProps({required this.started});
 }

+ 4 - 4
lib/responsive.dart

@@ -9,10 +9,10 @@ class Responsive extends StatelessWidget {
   final Widget desktop;
 
   const Responsive({
-    Key key,
-    @required this.mobile,
-    @required this.tablet,
-    @required this.desktop,
+    Key? key,
+    required this.mobile,
+    required this.tablet,
+    required this.desktop,
   }) : super(key: key);
 
 // This size work fine on my design, maybe you need some customization depends on your design

+ 1 - 2
lib/service/gameInit.dart

@@ -9,8 +9,7 @@ gameInit(Store<GameState> store, int mode) async {
 
   var key = 'total_' + mode.toString();
 
-  if (store.state.status.total != null &&
-      store.state.status.scores > store.state.status.total) {
+  if (store.state.status.scores > store.state.status.total) {
     prefs.setInt(key, store.state.status.scores);
   }
   var state = GameState.initial(mode);

+ 1 - 1
lib/store/game_state.dart

@@ -4,7 +4,7 @@ import 'package:flutter_2048/model/block_info.dart';
 import 'package:flutter_2048/model/game_status.dart';
 
 class GameState {
-  GameState({this.data, this.status, this.mode});
+  GameState({required this.data, required this.status, required this.mode});
 
   int mode;
   GameStatus status;

+ 8 - 6
lib/utils/sp_utils.dart

@@ -1,17 +1,20 @@
 import 'package:shared_preferences/shared_preferences.dart';
 
 class SpUtil {
-  static Future<SharedPreferences> sharedPreferences = SharedPreferences.getInstance();
+  static Future<SharedPreferences> sharedPreferences =
+      SharedPreferences.getInstance();
 
-  static Future<T> get<T>(String key) {
-    key ??= '';
+  static Future<T> get<T>(String key, T defaultValue) {
     return sharedPreferences.then((s) {
-      return s.get(key) as T;
+      if (s.get(key) == null) {
+        return defaultValue;
+      } else {
+        return s.get(key) as T;
+      }
     });
   }
 
   static Future<bool> save<T>(String key, T value) async {
-    key ??= '';
     return sharedPreferences.then((s) {
       if (value == null) {
         return s.remove(key);
@@ -37,7 +40,6 @@ class SpUtil {
   }
 
   static Future<bool> remove(String key) {
-    key ??= '';
     return sharedPreferences.then((s) {
       return s.remove(key);
     });

+ 2 - 2
lib/views/block/base_block.dart

@@ -4,7 +4,7 @@ import 'package:flutter_2048/utils/screen.dart';
 import 'package:flutter_redux/flutter_redux.dart';
 
 abstract class BaseBlock extends AnimatedWidget {
-  BaseBlock({Key key, Animation animation})
+  BaseBlock({Key? key, required Animation animation})
       : super(
           key: key,
           listenable: animation,
@@ -34,5 +34,5 @@ class BlockProps {
   double borderWidth;
   int mode;
 
-  BlockProps({this.blockWidth, this.borderWidth, this.mode});
+  BlockProps({required this.blockWidth, required this.borderWidth, required this.mode});
 }

+ 5 - 5
lib/views/block/combin_block.dart

@@ -10,11 +10,11 @@ class CombinBlock extends BaseBlock {
   final AnimationController moveController;
 
   CombinBlock({
-    Key key,
-    this.info,
-    this.mode,
-    this.moveController,
-    AnimationController combinController,
+    Key? key,
+    required this.info,
+    required this.mode,
+    required this.moveController,
+    required AnimationController combinController,
   }) : super(
           key: key,
           animation:

+ 4 - 4
lib/views/block/move_block.dart

@@ -16,10 +16,10 @@ class MoveBlock extends BaseBlock {
   final int mode;
 
   MoveBlock({
-    Key key,
-    this.info,
-    this.mode,
-    AnimationController controller,
+    Key? key,
+    required this.info,
+    required this.mode,
+    required AnimationController controller,
   }) : super(
           key: key,
           animation: Tween<double>(begin: getBegin(info, mode), end: 0)

+ 3 - 3
lib/views/block/new_block.dart

@@ -7,9 +7,9 @@ class NewBlock extends BaseBlock {
   final BlockInfo info;
 
   NewBlock({
-    Key key,
-    this.info,
-    AnimationController controller,
+    Key? key,
+    required this.info,
+    required AnimationController controller,
   }) : super(
           key: key,
           animation: Tween<double>(begin: 0.1, end: 1.0).animate(controller),

+ 3 - 3
lib/views/block/static_block.dart

@@ -8,9 +8,9 @@ class StaticBlock extends BaseBlock {
   final BlockInfo info;
 
   StaticBlock({
-    Key key,
-    this.info,
-    AnimationController controller,
+    Key? key,
+    required this.info,
+    required AnimationController controller,
   }) : super(
           key: key,
           animation:

+ 1 - 1
lib/views/blocks.dart

@@ -56,5 +56,5 @@ class BlocksProps {
   double padding;
   List<List<BlockInfo>> data;
 
-  BlocksProps({this.padding, this.mode, this.data});
+  BlocksProps({required this.padding, required this.mode, required this.data});
 }

+ 1 - 1
lib/views/game_bg.dart

@@ -71,5 +71,5 @@ class GameBgProps {
   double blockWidth; //块大小
   int mode; //游戏模式,3*3 4*4 6*6
 
-  GameBgProps({this.borderWidth, this.blockWidth, this.mode});
+  GameBgProps({required this.borderWidth, required this.blockWidth, required this.mode});
 }

+ 1 - 1
lib/views/mode_selector.dart

@@ -40,7 +40,7 @@ class ModeSelector extends StatelessWidget {
 }
 
 class ModeSelectorProps {
-  ModeSelectorProps({this.mode, this.onChange});
+  ModeSelectorProps({required this.mode, required this.onChange});
 
   int mode;
   Function onChange;

+ 4 - 4
lib/views/number_text.dart

@@ -4,7 +4,7 @@ class BlockStyle {
   Color textColor;
   Color background;
 
-  BlockStyle({this.textColor, this.background});
+  BlockStyle({required this.textColor, required this.background});
 }
 
 var styles = Map.fromEntries([
@@ -36,7 +36,7 @@ class NumberText extends StatelessWidget {
   final int value;
   final double size;
 
-  NumberText({this.value, this.size});
+  NumberText({required this.value, required this.size});
 
   @override
   Widget build(BuildContext context) {
@@ -57,8 +57,8 @@ class NumberText extends StatelessWidget {
           style: TextStyle(
             fontWeight: FontWeight.bold,
             color: (this.value ~/ 2048) > 1
-                ? styles[this.value ~/ 2048].textColor
-                : styles[this.value].textColor,
+                ? styles[this.value ~/ 2048]?.textColor
+                : styles[this.value]?.textColor,
             fontSize:
                 size / (numberText.length <= 2 ? 2 : numberText.length * 0.8),
           ),

+ 9 - 9
lib/views/playground.dart

@@ -79,9 +79,9 @@ class Playground extends StatelessWidget {
   void onVerticalDragEnd(DragEndDetails evt, PlaygroundProps props) {
     if (DateTime.now().millisecondsSinceEpoch - props.startTime >
             pressTimeout ||
-        evt.primaryVelocity.abs() < dragLength) return;
+        evt.primaryVelocity!.abs() < dragLength) return;
     // 是否ios和android纵轴是相反的?
-    if (evt.primaryVelocity < 0) {
+    if (evt.primaryVelocity! < 0) {
       props.onUp();
     } else {
       props.onDown();
@@ -99,12 +99,12 @@ class PlaygroundProps {
   Function onDown;
 
   PlaygroundProps({
-    this.end,
-    this.mode,
-    this.startTime,
-    this.onDown,
-    this.onLeft,
-    this.onRight,
-    this.onUp,
+    required this.end,
+    required this.mode,
+    required this.startTime,
+    required this.onDown,
+    required this.onLeft,
+    required this.onRight,
+    required this.onUp,
   });
 }

+ 1 - 1
lib/views/scores.dart

@@ -128,7 +128,7 @@ class Scores extends StatelessWidget {
 }
 
 class ScoresProps {
-  ScoresProps({this.mode, this.total, this.scores, this.isEnd, this.reset});
+  ScoresProps({required this.mode, required this.total, required this.scores, required this.isEnd, required this.reset});
 
   int mode;
   int total;

+ 2 - 0
linux/flutter/generated_plugin_registrant.cc

@@ -2,6 +2,8 @@
 //  Generated file. Do not edit.
 //
 
+// clang-format off
+
 #include "generated_plugin_registrant.h"
 
 

+ 2 - 0
linux/flutter/generated_plugin_registrant.h

@@ -2,6 +2,8 @@
 //  Generated file. Do not edit.
 //
 
+// clang-format off
+
 #ifndef GENERATED_PLUGIN_REGISTRANT_
 #define GENERATED_PLUGIN_REGISTRANT_
 

+ 8 - 0
linux/flutter/generated_plugins.cmake

@@ -5,6 +5,9 @@
 list(APPEND FLUTTER_PLUGIN_LIST
 )
 
+list(APPEND FLUTTER_FFI_PLUGIN_LIST
+)
+
 set(PLUGIN_BUNDLED_LIBRARIES)
 
 foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
   list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
   list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
 endforeach(plugin)
+
+foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
+  add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
+  list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
+endforeach(ffi_plugin)

+ 11 - 18
pubspec.lock

@@ -42,7 +42,7 @@ packages:
       name: collection
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.15.0"
+    version: "1.16.0"
   cupertino_icons:
     dependency: "direct main"
     description:
@@ -70,7 +70,7 @@ packages:
       name: fake_async
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.2.0"
+    version: "1.3.0"
   ffi:
     dependency: transitive
     description:
@@ -101,14 +101,14 @@ packages:
       name: flutter_redux
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "0.8.2"
+    version: "0.10.0"
   flutter_screenutil:
     dependency: "direct main"
     description:
       name: flutter_screenutil
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "4.0.4+1"
+    version: "5.5.3+2"
   flutter_test:
     dependency: "direct dev"
     description: flutter
@@ -132,7 +132,7 @@ packages:
       name: js
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "0.6.3"
+    version: "0.6.4"
   matcher:
     dependency: transitive
     description:
@@ -146,7 +146,7 @@ packages:
       name: material_color_utilities
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "0.1.3"
+    version: "0.1.4"
   meta:
     dependency: transitive
     description:
@@ -160,7 +160,7 @@ packages:
       name: path
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.8.0"
+    version: "1.8.1"
   path_provider_linux:
     dependency: transitive
     description:
@@ -284,7 +284,7 @@ packages:
       name: source_span
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.8.1"
+    version: "1.8.2"
   stack_trace:
     dependency: transitive
     description:
@@ -319,21 +319,14 @@ packages:
       name: test_api
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "0.4.8"
-  typed_data:
-    dependency: transitive
-    description:
-      name: typed_data
-      url: "https://pub.flutter-io.cn"
-    source: hosted
-    version: "1.3.0"
+    version: "0.4.9"
   vector_math:
     dependency: transitive
     description:
       name: vector_math
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "2.1.1"
+    version: "2.1.2"
   win32:
     dependency: transitive
     description:
@@ -349,5 +342,5 @@ packages:
     source: hosted
     version: "0.2.0+1"
 sdks:
-  dart: ">=2.15.0 <3.0.0"
+  dart: ">=2.17.6 <3.0.0"
   flutter: ">=2.8.0"

+ 3 - 3
pubspec.yaml

@@ -3,7 +3,7 @@ description: 2048 game.
 version: 1.0.0+1
 
 environment:
-  sdk: ">=2.7.0 <3.0.0"
+  sdk: ">=2.17.6 <3.0.0"
 
 dependencies:
   flutter:
@@ -13,9 +13,9 @@ dependencies:
     sdk: flutter
   intl: ^0.17.0
   cupertino_icons: ^1.0.3 # ios风格图标
-  flutter_screenutil: ^4.0.3+2 # 屏幕工具
+  flutter_screenutil: ^5.5.3+2 # 屏幕工具
   device_info: ^2.0.2
-  flutter_redux: ^0.8.2 # 状态管理
+  flutter_redux: ^0.10.0 # 状态管理
   redux_thunk: ^0.4.0
   shared_preferences: ^2.0.7