From d51550b6c0bea0e3bd168e20b26e55f044ce7be4 Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Wed, 30 Mar 2022 14:22:23 +0800 Subject: [PATCH] null-safe --- example/.flutter-plugins-dependencies | 2 +- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- .../ios/Flutter/flutter_export_environment.sh | 14 ++-- example/ios/Runner.xcodeproj/project.pbxproj | 10 +-- .../contents.xcworkspacedata | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/pubspec.lock | 45 ++++++----- lib/albc_tools.dart | 4 +- lib/alibc_model.dart | 44 +++++----- lib/flutter_alibc.dart | 80 +++++++++---------- pubspec.lock | 45 ++++++----- pubspec.yaml | 2 +- 12 files changed, 132 insertions(+), 120 deletions(-) diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 3940a51..30666d3 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_alibc","path":"/Users/fnuser04/Documents/flutterAPP/zhiying_flutter_alibc/","dependencies":[]}],"android":[{"name":"flutter_alibc","path":"/Users/fnuser04/Documents/flutterAPP/zhiying_flutter_alibc/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_alibc","dependencies":[]}],"date_created":"2021-04-17 11:06:38.571844","version":"1.22.0"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_alibc","path":"/Users/fnuouser/Documents/code/zhiying/zhiying_flutter_alibc/","dependencies":[]}],"android":[{"name":"flutter_alibc","path":"/Users/fnuouser/Documents/code/zhiying/zhiying_flutter_alibc/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_alibc","dependencies":[]}],"date_created":"2022-03-30 14:17:04.674376","version":"2.10.3"} \ No newline at end of file diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..f2872cf 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index f3ad506..223afaf 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -1,16 +1,14 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/fnuser04/Documents/flutterModel/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/fnuser04/Documents/flutterAPP/zhiying_flutter_alibc/example" -export "FLUTTER_TARGET=/Users/fnuser04/Documents/flutterAPP/zhiying_flutter_alibc/example/lib/main.dart" +export "FLUTTER_ROOT=/Users/fnuouser/Documents/code/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/fnuouser/Documents/code/zhiying/zhiying_flutter_alibc/example" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=/Users/fnuouser/Documents/code/zhiying/zhiying_flutter_alibc/example/lib/main.dart" export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build/ios" -export "OTHER_LDFLAGS=$(inherited) -framework Flutter" -export "FLUTTER_FRAMEWORK_DIR=/Users/fnuser04/Documents/flutterModel/flutter/bin/cache/artifacts/engine/ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" -export "DART_DEFINES=flutter.inspector.structuredErrors%3Dtrue" +export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.packages" +export "PACKAGE_CONFIG=/Users/fnuouser/Documents/code/zhiying/zhiying_flutter_alibc/example/.dart_tool/package_config.json" diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index abdfcb9..26fc84d 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -191,7 +191,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -394,7 +394,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -483,7 +483,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -532,7 +532,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..3db53b6 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =2.10.0-110 <2.11.0" + dart: ">=2.14.0 <3.0.0" diff --git a/lib/albc_tools.dart b/lib/albc_tools.dart index 78554bf..a8df917 100644 --- a/lib/albc_tools.dart +++ b/lib/albc_tools.dart @@ -46,8 +46,8 @@ class AlibcTools { } // 设置淘宝客数据 - static Map getTaokeMap(TaokeParams taokeParams) { - Map taoKe; + static Map? getTaokeMap(TaokeParams? taokeParams) { + Map? taoKe; if (taokeParams != null) { taoKe = { "adzoneId": taokeParams.adzoneId ?? "", diff --git a/lib/alibc_model.dart b/lib/alibc_model.dart index 7e91142..b3702b0 100644 --- a/lib/alibc_model.dart +++ b/lib/alibc_model.dart @@ -3,20 +3,20 @@ import 'alibc_const_key.dart'; class InitModel { // 错误码 - final String errorCode; + final String? errorCode; // 错误信息 - final String errorMessage; + final String? errorMessage; InitModel(this.errorCode, this.errorMessage); } class LoginModel { // 错误码 - final String errorCode; + final String? errorCode; // 错误信息 - final String errorMessage; + final String? errorMessage; - UserModel data; + UserModel? data; LoginModel(this.errorCode, this.errorMessage, {this.data}); } @@ -24,13 +24,13 @@ class LoginModel { // 用户信息 class UserModel { // 用户昵称 - final String nick; + final String? nick; // 头像地址 - final String avatarUrl; - final String openId; - final String openSid; - final String topAccessToken; - final String topAuthCode; + final String? avatarUrl; + final String? openId; + final String? openSid; + final String? topAccessToken; + final String? topAuthCode; UserModel(this.nick, this.avatarUrl, this.openId, this.openSid, this.topAccessToken, this.topAuthCode); } @@ -38,11 +38,11 @@ class UserModel { // 淘宝客的参数 class TaokeParams { //有adzoneId则pid失效 - String adzoneId; - String pid; - String unionId; - String subPid; - Map extParams; + String? adzoneId; + String? pid; + String? unionId; + String? subPid; + Map? extParams; TaokeParams( {this.adzoneId, this.pid, this.unionId, this.subPid, this.extParams}); } @@ -50,13 +50,13 @@ class TaokeParams { // url打开或者page打开等的数据 class TradeResult { // 错误码,0为成功,非0为失败 - String errorCode; + String? errorCode; // 错误信息 - String errorMessage; + String? errorMessage; - TradeResultType type; + TradeResultType? type; - PayResult payResult; + PayResult? payResult; // AddCardResult addCardResult; // Android没有,所以去掉 // TradeFailResult tradeFailResult; @@ -73,9 +73,9 @@ class TradeResult { // 付款成功的result class PayResult { // 支付成功的订单 - final List paySuccessOrders; + final List? paySuccessOrders; // 支付失败的订单 - final List payFailedOrders; + final List? payFailedOrders; PayResult(this.paySuccessOrders, this.payFailedOrders); } diff --git a/lib/flutter_alibc.dart b/lib/flutter_alibc.dart index 9994ab3..f47b9e6 100644 --- a/lib/flutter_alibc.dart +++ b/lib/flutter_alibc.dart @@ -24,8 +24,8 @@ class FlutterAlibc { // ..setMethodCallHandler(_handler); - static Future get platformVersion async { - final String version = await _channel.invokeMethod('getPlatformVersion'); + static Future get platformVersion async { + final String? version = await _channel.invokeMethod('getPlatformVersion'); return version; } @@ -36,8 +36,8 @@ class FlutterAlibc { /// errorCode, //0为初始化成功,其他为失败 /// errorMessage, //message ///} - static Future initAlibc({String version, String appName}) async { - Map result = await _channel.invokeMethod("initAlibc", {"version": version, "appName": appName}); + static Future initAlibc({String? version, String? appName}) async { + Map result = await (_channel.invokeMethod("initAlibc", {"version": version, "appName": appName}) as FutureOr>); return InitModel(result[AlibcConstKey.errorCode], result[AlibcConstKey.errorMessage]); } @@ -47,7 +47,7 @@ class FlutterAlibc { /// @return: 成功则返回的data为用户信息,失败则没有data /// static Future loginTaoBao() async { - Map result = await _channel.invokeMethod("loginTaoBao"); + Map result = await (_channel.invokeMethod("loginTaoBao") as FutureOr>); // 判断成功还是失败 if (result[AlibcConstKey.errorCode] != "0") { return LoginModel( @@ -74,17 +74,17 @@ class FlutterAlibc { /// @param {type} /// @return: /// Map - static Future> taoKeLogin({ - @required String url, + static Future?> taoKeLogin({ + required String url, AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, bool isNeedCustomNativeFailMode = false, AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTaoBao, - TaokeParams taokeParams, - String backUrl, + TaokeParams? taokeParams, + String? backUrl, }) async { - Map taoKe = AlibcTools.getTaokeMap(taokeParams); - Map result = await _channel.invokeMethod("taoKeLogin", { + Map? taoKe = AlibcTools.getTaokeMap(taokeParams); + Map? result = await _channel.invokeMethod("taoKeLogin", { "url": url, "openType": openType.index, "isNeedCustomNativeFailMode": isNeedCustomNativeFailMode, @@ -102,8 +102,8 @@ class FlutterAlibc { /// name app名字 /// alibcAppKey 百川Key /// Map - static Future> taoKeLoginNew(String name, String alibcAppKey) async { - Map result = await _channel.invokeMethod("taoKeLoginNew", { + static Future?> taoKeLoginNew(String name, String alibcAppKey) async { + Map? result = await _channel.invokeMethod("taoKeLoginNew", { "name": name, "alibcAppKey": alibcAppKey, }); @@ -116,8 +116,8 @@ class FlutterAlibc { /// @param {type} /// @return: /// Map - static Future> taoKeLoginNewIOS(String name, String alibcAppKey) async { - Map result = await _channel.invokeMethod("taoKeLogin", { + static Future?> taoKeLoginNewIOS(String name, String alibcAppKey) async { + Map? result = await _channel.invokeMethod("taoKeLogin", { "name": name, "alibcAppKey": alibcAppKey, }); @@ -137,15 +137,15 @@ class FlutterAlibc { /// @return: /// static Future openByUrl( - {@required String url, + {required String url, AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, bool isNeedCustomNativeFailMode = false, AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTmall, - TaokeParams taokeParams, - String backUrl, + TaokeParams? taokeParams, + String? backUrl, bool isAuth = false}) async { - Map taoKe = AlibcTools.getTaokeMap(taokeParams); + Map? taoKe = AlibcTools.getTaokeMap(taokeParams); var result = await _channel.invokeMethod("openByUrl", { "url": url, "openType": openType.index, @@ -182,20 +182,20 @@ class FlutterAlibc { /// @return: /// static Future openItemDetail({ - @required String itemID, + required String itemID, // iOS独占 // bool isNeedPush = false, AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, bool isNeedCustomNativeFailMode = false, AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTmall, - TaokeParams taokeParams, + TaokeParams? taokeParams, // 额外需要追踪的业务数据 - Map trackParam, - String backUrl, + Map? trackParam, + String? backUrl, }) async { - Map taoKe = AlibcTools.getTaokeMap(taokeParams); - Map result = await _channel.invokeMethod("openItemDetail", { + Map? taoKe = AlibcTools.getTaokeMap(taokeParams); + Map result = await (_channel.invokeMethod("openItemDetail", { "itemID": itemID, // "isNeedPush": isNeedPush, "openType": openType.index, @@ -205,7 +205,7 @@ class FlutterAlibc { "taokeParams": taoKe, "trackParam": trackParam, "backUrl": backUrl - }); + }) as FutureOr>); TradeResult tradeResult = AlibcTools.getTradeResult(result); return tradeResult; } @@ -217,21 +217,21 @@ class FlutterAlibc { /// @return: /// static Future openShop({ - @required String shopId, + required String shopId, // iOS独占 // bool isNeedPush = false, AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, bool isNeedCustomNativeFailMode = false, AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTmall, - TaokeParams taokeParams, + TaokeParams? taokeParams, // 额外需要追踪的业务数据 - Map trackParam, - String backUrl, + Map? trackParam, + String? backUrl, }) async { - Map taoKe = AlibcTools.getTaokeMap(taokeParams); + Map? taoKe = AlibcTools.getTaokeMap(taokeParams); - Map result = await _channel.invokeMethod("openShop", { + Map result = await (_channel.invokeMethod("openShop", { "shopId": shopId, // "isNeedPush": isNeedPush, "openType": openType.index, @@ -241,7 +241,7 @@ class FlutterAlibc { "taokeParams": taoKe, "trackParam": trackParam, "backUrl": backUrl - }); + }) as FutureOr>); TradeResult tradeResult = AlibcTools.getTradeResult(result); return tradeResult; } @@ -258,14 +258,14 @@ class FlutterAlibc { bool isNeedCustomNativeFailMode = false, AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTmall, - TaokeParams taokeParams, + TaokeParams? taokeParams, // 额外需要追踪的业务数据 - Map trackParam, - String backUrl, + Map? trackParam, + String? backUrl, }) async { - Map taoKe = AlibcTools.getTaokeMap(taokeParams); + Map? taoKe = AlibcTools.getTaokeMap(taokeParams); - Map result = await _channel.invokeMethod("openCart", { + Map result = await (_channel.invokeMethod("openCart", { // "isNeedPush": isNeedPush, "openType": openType.index, "isNeedCustomNativeFailMode": isNeedCustomNativeFailMode, @@ -274,7 +274,7 @@ class FlutterAlibc { "taokeParams": taoKe, "trackParam": trackParam, "backUrl": backUrl - }); + }) as FutureOr>); TradeResult tradeResult = AlibcTools.getTradeResult(result); return tradeResult; } @@ -289,7 +289,7 @@ class FlutterAlibc { _channel.invokeMethod("useAlipayNative", {"isNeed": isNeed}); } - static Future getUdid() async { + static Future getUdid() async { var map = await _channel.invokeMethod("getUdid"); print(map); return map['udid']; diff --git a/pubspec.lock b/pubspec.lock index 5acf180..e12fb22 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.3.1" clock: dependency: transitive description: name: clock url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.flutter-io.cn" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,28 @@ packages: name: matcher url: "https://pub.flutter-io.cn" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.1.3" meta: dependency: transitive description: name: meta url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.7.0" path: dependency: transitive description: name: path url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -92,55 +99,55 @@ packages: name: source_span url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.flutter-io.cn" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.4.8" typed_data: dependency: transitive description: name: typed_data url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.1" sdks: - dart: ">=2.10.0-110 <2.11.0" + dart: ">=2.14.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index f5b58f8..ef01e6b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ author: wx homepage: https://github.com/FlutterTaoBaoKe/flutter_alibc.git environment: - sdk: '>=2.1.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: