diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 46de6ce..058679d 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":"mop","path":"/Users/beetle/Desktop/finogeeks/gitlab/finosprite/finclip-flutter-sdk/","dependencies":[]}],"android":[{"name":"mop","path":"/Users/beetle/Desktop/finogeeks/gitlab/finosprite/finclip-flutter-sdk/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"mop","dependencies":[]}],"date_created":"2021-08-13 09:53:09.007824","version":"2.2.2"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"mop","path":"/Users/weichengzhu/dev/flutter/mop-flutter-sdk/","dependencies":[]}],"android":[{"name":"mop","path":"/Users/weichengzhu/dev/flutter/mop-flutter-sdk/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"mop","dependencies":[]}],"date_created":"2021-08-18 22:10:00.612245","version":"2.2.3"} \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index b488f98..dd67e41 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,124 +1,124 @@ -import 'package:flutter/material.dart'; -import 'dart:async'; -import 'dart:io'; -import 'package:mop/mop.dart'; +// import 'package:flutter/material.dart'; +// import 'dart:async'; +// import 'dart:io'; +// import 'package:mop/mop.dart'; -void main() => runApp(MyApp()); +// void main() => runApp(MyApp()); -class MyApp extends StatefulWidget { - @override - _MyAppState createState() => _MyAppState(); -} +// class MyApp extends StatefulWidget { +// @override +// _MyAppState createState() => _MyAppState(); +// } -class _MyAppState extends State { - @override - void initState() { - super.initState(); - init(); - } +// class _MyAppState extends State { +// @override +// void initState() { +// super.initState(); +// init(); +// } - // Platform messages are asynchronous, so we initialize in an async method. - Future init() async { - if (Platform.isIOS) { - final res = await Mop.instance.initialize( - '22LyZEib0gLTQdU3MUauAZ0pZVbKTWGmNN6Lx8hXhIkA', '74bde5fad53a817c', - apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop'); - print(res); - } else if (Platform.isAndroid) { - final res = await Mop.instance.initialize( - '22LyZEib0gLTQdU3MUauAZ0pZVbKTWGmNN6Lx8hXhIkA', '74bde5fad53a817c', - apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop'); - print(res); - } - if (!mounted) return; - } +// // Platform messages are asynchronous, so we initialize in an async method. +// Future init() async { +// if (Platform.isIOS) { +// final res = await Mop.instance.initialize( +// '22LyZEib0gLTQdU3MUauAZ0pZVbKTWGmNN6Lx8hXhIkA', '74bde5fad53a817c', +// apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop'); +// print(res); +// } else if (Platform.isAndroid) { +// final res = await Mop.instance.initialize( +// '22LyZEib0gLTQdU3MUauAZ0pZVbKTWGmNN6Lx8hXhIkA', '74bde5fad53a817c', +// apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop'); +// print(res); +// } +// if (!mounted) return; +// } - // 5e637a18cbfae4000170fa7a - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('凡泰极客小程序 Flutter 插件'), - ), - body: Center( - child: Container( - padding: EdgeInsets.only( - top: 20, - ), - child: Column( - children: [ - Container( - width: 140, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(5)), - gradient: LinearGradient( - colors: const [Color(0xFF12767e), Color(0xFF0dabb8)], - stops: const [0.0, 1.0], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - ), - ), - child: FlatButton( - onPressed: () { - Mop.instance.openApplet('5ea03fa563cb900001d73863', - path: 'pages/index/index', query: ''); - }, - child: Text( - '打开画图小程序', - style: TextStyle(color: Colors.white), - ), - ), - ), - SizedBox(height: 30), - Container( - width: 140, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(5)), - gradient: LinearGradient( - colors: const [Color(0xFF12767e), Color(0xFF0dabb8)], - stops: const [0.0, 1.0], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - ), - ), - child: FlatButton( - onPressed: () { - Mop.instance.openApplet('5ea0401463cb900001d73865'); - }, - child: Text( - '打开官方小程序', - style: TextStyle(color: Colors.white), - ), - ), - ), - SizedBox(height: 30), - Container( - width: 140, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(5)), - gradient: LinearGradient( - colors: const [Color(0xFF12767e), Color(0xFF0dabb8)], - stops: const [0.0, 1.0], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - ), - ), - child: FlatButton( - onPressed: () { - Mop.instance.openApplet('5ea0412663cb900001d73867'); - }, - child: Text( - '我的对账单', - style: TextStyle(color: Colors.white), - ), - ), - ), - ], - ), - ), - ), - ), - ); - } -} +// // 5e637a18cbfae4000170fa7a +// @override +// Widget build(BuildContext context) { +// return MaterialApp( +// home: Scaffold( +// appBar: AppBar( +// title: const Text('凡泰极客小程序 Flutter 插件'), +// ), +// body: Center( +// child: Container( +// padding: EdgeInsets.only( +// top: 20, +// ), +// child: Column( +// children: [ +// Container( +// width: 140, +// decoration: BoxDecoration( +// borderRadius: BorderRadius.all(Radius.circular(5)), +// gradient: LinearGradient( +// colors: const [Color(0xFF12767e), Color(0xFF0dabb8)], +// stops: const [0.0, 1.0], +// begin: Alignment.topCenter, +// end: Alignment.bottomCenter, +// ), +// ), +// child: FlatButton( +// onPressed: () { +// Mop.instance.openApplet('5ea03fa563cb900001d73863', +// path: 'pages/index/index', query: ''); +// }, +// child: Text( +// '打开画图小程序', +// style: TextStyle(color: Colors.white), +// ), +// ), +// ), +// SizedBox(height: 30), +// Container( +// width: 140, +// decoration: BoxDecoration( +// borderRadius: BorderRadius.all(Radius.circular(5)), +// gradient: LinearGradient( +// colors: const [Color(0xFF12767e), Color(0xFF0dabb8)], +// stops: const [0.0, 1.0], +// begin: Alignment.topCenter, +// end: Alignment.bottomCenter, +// ), +// ), +// child: FlatButton( +// onPressed: () { +// Mop.instance.openApplet('5ea0401463cb900001d73865'); +// }, +// child: Text( +// '打开官方小程序', +// style: TextStyle(color: Colors.white), +// ), +// ), +// ), +// SizedBox(height: 30), +// Container( +// width: 140, +// decoration: BoxDecoration( +// borderRadius: BorderRadius.all(Radius.circular(5)), +// gradient: LinearGradient( +// colors: const [Color(0xFF12767e), Color(0xFF0dabb8)], +// stops: const [0.0, 1.0], +// begin: Alignment.topCenter, +// end: Alignment.bottomCenter, +// ), +// ), +// child: FlatButton( +// onPressed: () { +// Mop.instance.openApplet('5ea0412663cb900001d73867'); +// }, +// child: Text( +// '我的对账单', +// style: TextStyle(color: Colors.white), +// ), +// ), +// ), +// ], +// ), +// ), +// ), +// ), +// ); +// } +// } diff --git a/example/pubspec.lock b/example/pubspec.lock index 75c4c64..9909940 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,56 +5,56 @@ packages: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.15.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.1.3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" flutter: @@ -71,14 +71,14 @@ packages: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" mop: @@ -87,12 +87,12 @@ packages: path: ".." relative: true source: path - version: "2.33.5" + version: "2.33.3" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.0" sky_engine: @@ -104,58 +104,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.3.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" sdks: dart: ">=2.12.0 <3.0.0" - flutter: ">=1.10.0" + flutter: ">=2.2.3" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index bd40a2d..ce89754 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -3,7 +3,7 @@ description: Demonstrates how to use the mop plugin. publish_to: 'none' environment: - sdk: '>=2.1.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 9808a6f..e7b7478 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -1,27 +1,27 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. +// // This is a basic Flutter widget test. +// // +// // To perform an interaction with a widget in your test, use the WidgetTester +// // utility that Flutter provides. For example, you can send tap and scroll +// // gestures. You can also use WidgetTester to find child widgets in the widget +// // tree, read text, and verify that the values of widget properties are correct. -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter_test/flutter_test.dart'; -import 'package:mop_example/main.dart'; +// import 'package:mop_example/main.dart'; -void main() { - testWidgets('Verify Platform version', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); +// void main() { +// testWidgets('Verify Platform version', (WidgetTester tester) async { +// // Build our app and trigger a frame. +// await tester.pumpWidget(MyApp()); - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data.startsWith('Running on:'), - ), - findsOneWidget, - ); - }); -} +// // Verify that platform version is retrieved. +// expect( +// find.byWidgetPredicate( +// (Widget widget) => widget is Text && +// widget.data.startsWith('Running on:'), +// ), +// findsOneWidget, +// ); +// }); +// } diff --git a/lib/mop.dart b/lib/mop.dart index 7590e2d..feeef6d 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -11,9 +11,9 @@ typedef ExtensionApiHandler = Future Function(dynamic params); class Mop { static final Mop _instance = new Mop._internal(); - MethodChannel _channel; - EventChannel _mopEventChannel; - int eventId = 0; + late MethodChannel _channel; + late EventChannel _mopEventChannel; + late int eventId = 0; List> _mopEventQueye = >[]; Map _extensionApis = {}; @@ -22,7 +22,7 @@ class Mop { return _instance; } - Mop._internal() { + Mop._internal() { print('mop: _internal'); // init _channel = new MethodChannel('mop'); @@ -70,11 +70,11 @@ class Mop { /// [disablePermission] is optional. /// Future initialize(String appkey, String secret, - {String apiServer, - String apiPrefix, - String cryptType, - bool disablePermission, - String userId, + {required String apiServer, + required String apiPrefix, + required String cryptType, + required bool disablePermission, + required String userId, bool encryptServerData = false, bool debug = false}) async { final Map ret = await _channel.invokeMethod('initialize', { @@ -103,26 +103,26 @@ class Mop { /// [cryptType] is optional. cryptType, should be MD5/SM Future openApplet( final String appId, { - final String path, - final String query, - final int sequence, - final String apiServer, - final String apiPrefix, - final String fingerprint, - final String cryptType, - final String scene, + required final String path, + required final String query, + required final int sequence, + required final String apiServer, + required final String apiPrefix, + required final String fingerprint, + required final String cryptType, + required final String scene, }) async { Map params = {'appId': appId}; Map param = {}; - if (path != null) param["path"] = path; - if (query != null) param["query"] = query; + param["path"] = path; + param["query"] = query; if (param.length > 0) params["params"] = param; - if (sequence != null) params["sequence"] = sequence; - if (apiServer != null) params["apiServer"] = apiServer; - if (apiPrefix != null) params["apiPrefix"] = apiPrefix; - if (fingerprint != null) params["fingerprint"] = fingerprint; - if (cryptType != null) params["cryptType"] = cryptType; - if (scene != null) param["scene"] = scene; + params["sequence"] = sequence; + params["apiServer"] = apiServer; + params["apiPrefix"] = apiPrefix; + params["fingerprint"] = fingerprint; + params["cryptType"] = cryptType; + param["scene"] = scene; final Map ret = await _channel.invokeMethod('openApplet', params); return ret; } @@ -135,7 +135,7 @@ class Mop { /// Future> currentApplet() async { final ret = await _channel.invokeMapMethod("currentApplet"); - return Map.from(ret); + return Map.from(ret!); } /// @@ -160,7 +160,7 @@ class Mop { Future sdkVersion() async { return await _channel .invokeMapMethod("sdkVersion") - .then((value) => value["data"]); + .then((value) => value?["data"]); } /// @@ -178,7 +178,7 @@ class Mop { String qrCode, String apiServer) async { final ret = await _channel.invokeMapMethod("parseAppletInfoFromWXQrCode", {"qrCode": qrCode, "apiServer": apiServer}); - return Map.from(ret); + return Map.from(ret!); } /// @@ -226,7 +226,7 @@ class Mop { Future getSMSign(String plainText) async { var result = await _channel.invokeMapMethod("smsign", {'plainText': plainText}); - var data = result['data']['data']; + var data = result?['data']['data']; print(data); return data; } diff --git a/pubspec.lock b/pubspec.lock index 65b1ee6..98ff506 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,49 +5,49 @@ packages: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.15.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" flutter: @@ -64,21 +64,21 @@ packages: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.0" sky_engine: @@ -90,58 +90,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.3.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" sdks: dart: ">=2.12.0 <3.0.0" - flutter: ">=1.10.0" + flutter: ">=2.2.3" diff --git a/pubspec.yaml b/pubspec.yaml index 5356e25..6246efe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,8 +4,8 @@ version: '2.33.3' homepage: https://github.com/finogeeks/mop-flutter-sdk environment: - sdk: '>=2.1.0 <3.0.0' - flutter: '^1.10.0' + sdk: '>=2.12.0 <3.0.0' + flutter: '^2.2.3' dependencies: flutter: