migrate to null safe

master
Weicheng Zhu 2021-08-18 22:12:50 +08:00
parent a4dfe2f8e6
commit e46c5238bc
3 changed files with 161 additions and 161 deletions

View File

@ -1,124 +1,124 @@
// import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// import 'dart:async'; import 'dart:async';
// import 'dart:io'; import 'dart:io';
// import 'package:mop/mop.dart'; import 'package:mop/mop.dart';
// void main() => runApp(MyApp()); void main() => runApp(MyApp());
// class MyApp extends StatefulWidget { class MyApp extends StatefulWidget {
// @override @override
// _MyAppState createState() => _MyAppState(); _MyAppState createState() => _MyAppState();
// } }
// class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
// @override @override
// void initState() { void initState() {
// super.initState(); super.initState();
// init(); init();
// } }
// // Platform messages are asynchronous, so we initialize in an async method. // Platform messages are asynchronous, so we initialize in an async method.
// Future<void> init() async { Future<void> init() async {
// if (Platform.isIOS) { if (Platform.isIOS) {
// final res = await Mop.instance.initialize( final res = await Mop.instance.initialize(
// '22LyZEib0gLTQdU3MUauAZ0pZVbKTWGmNN6Lx8hXhIkA', '74bde5fad53a817c', '22LyZEib0gLTQdU3MUauAZ0pZVbKTWGmNN6Lx8hXhIkA', '74bde5fad53a817c',
// apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop'); apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop');
// print(res); print(res);
// } else if (Platform.isAndroid) { } else if (Platform.isAndroid) {
// final res = await Mop.instance.initialize( final res = await Mop.instance.initialize(
// '22LyZEib0gLTQdU3MUauAZ0pZVbKTWGmNN6Lx8hXhIkA', '74bde5fad53a817c', '22LyZEib0gLTQdU3MUauAZ0pZVbKTWGmNN6Lx8hXhIkA', '74bde5fad53a817c',
// apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop'); apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop');
// print(res); print(res);
// } }
// if (!mounted) return; if (!mounted) return;
// } }
// // 5e637a18cbfae4000170fa7a // 5e637a18cbfae4000170fa7a
// @override @override
// Widget build(BuildContext context) { Widget build(BuildContext context) {
// return MaterialApp( return MaterialApp(
// home: Scaffold( home: Scaffold(
// appBar: AppBar( appBar: AppBar(
// title: const Text('凡泰极客小程序 Flutter 插件'), title: const Text('凡泰极客小程序 Flutter 插件'),
// ), ),
// body: Center( body: Center(
// child: Container( child: Container(
// padding: EdgeInsets.only( padding: EdgeInsets.only(
// top: 20, top: 20,
// ), ),
// child: Column( child: Column(
// children: <Widget>[ children: <Widget>[
// Container( Container(
// width: 140, width: 140,
// decoration: BoxDecoration( decoration: BoxDecoration(
// borderRadius: BorderRadius.all(Radius.circular(5)), borderRadius: BorderRadius.all(Radius.circular(5)),
// gradient: LinearGradient( gradient: LinearGradient(
// colors: const [Color(0xFF12767e), Color(0xFF0dabb8)], colors: const [Color(0xFF12767e), Color(0xFF0dabb8)],
// stops: const [0.0, 1.0], stops: const [0.0, 1.0],
// begin: Alignment.topCenter, begin: Alignment.topCenter,
// end: Alignment.bottomCenter, end: Alignment.bottomCenter,
// ), ),
// ), ),
// child: FlatButton( child: FlatButton(
// onPressed: () { onPressed: () {
// Mop.instance.openApplet('5ea03fa563cb900001d73863', Mop.instance.openApplet('5ea03fa563cb900001d73863',
// path: 'pages/index/index', query: ''); path: 'pages/index/index', query: '');
// }, },
// child: Text( child: Text(
// '打开画图小程序', '打开画图小程序',
// style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
// ), ),
// ), ),
// ), ),
// SizedBox(height: 30), SizedBox(height: 30),
// Container( Container(
// width: 140, width: 140,
// decoration: BoxDecoration( decoration: BoxDecoration(
// borderRadius: BorderRadius.all(Radius.circular(5)), borderRadius: BorderRadius.all(Radius.circular(5)),
// gradient: LinearGradient( gradient: LinearGradient(
// colors: const [Color(0xFF12767e), Color(0xFF0dabb8)], colors: const [Color(0xFF12767e), Color(0xFF0dabb8)],
// stops: const [0.0, 1.0], stops: const [0.0, 1.0],
// begin: Alignment.topCenter, begin: Alignment.topCenter,
// end: Alignment.bottomCenter, end: Alignment.bottomCenter,
// ), ),
// ), ),
// child: FlatButton( child: FlatButton(
// onPressed: () { onPressed: () {
// Mop.instance.openApplet('5ea0401463cb900001d73865'); Mop.instance.openApplet('5ea0401463cb900001d73865');
// }, },
// child: Text( child: Text(
// '打开官方小程序', '打开官方小程序',
// style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
// ), ),
// ), ),
// ), ),
// SizedBox(height: 30), SizedBox(height: 30),
// Container( Container(
// width: 140, width: 140,
// decoration: BoxDecoration( decoration: BoxDecoration(
// borderRadius: BorderRadius.all(Radius.circular(5)), borderRadius: BorderRadius.all(Radius.circular(5)),
// gradient: LinearGradient( gradient: LinearGradient(
// colors: const [Color(0xFF12767e), Color(0xFF0dabb8)], colors: const [Color(0xFF12767e), Color(0xFF0dabb8)],
// stops: const [0.0, 1.0], stops: const [0.0, 1.0],
// begin: Alignment.topCenter, begin: Alignment.topCenter,
// end: Alignment.bottomCenter, end: Alignment.bottomCenter,
// ), ),
// ), ),
// child: FlatButton( child: FlatButton(
// onPressed: () { onPressed: () {
// Mop.instance.openApplet('5ea0412663cb900001d73867'); Mop.instance.openApplet('5ea0412663cb900001d73867');
// }, },
// child: Text( child: Text(
// '我的对账单', '我的对账单',
// style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
// ), ),
// ), ),
// ), ),
// ], ],
// ), ),
// ), ),
// ), ),
// ), ),
// ); );
// } }
// } }

View File

@ -1,27 +1,27 @@
// // This is a basic Flutter widget test. // This is a basic Flutter widget test.
// // //
// // To perform an interaction with a widget in your test, use the WidgetTester // 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 // 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 // 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. // tree, read text, and verify that the values of widget properties are correct.
// import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
// import 'package:mop_example/main.dart'; import 'package:mop_example/main.dart';
// void main() { void main() {
// testWidgets('Verify Platform version', (WidgetTester tester) async { testWidgets('Verify Platform version', (WidgetTester tester) async {
// // Build our app and trigger a frame. // Build our app and trigger a frame.
// await tester.pumpWidget(MyApp()); await tester.pumpWidget(MyApp());
// // Verify that platform version is retrieved. // Verify that platform version is retrieved.
// expect( expect(
// find.byWidgetPredicate( find.byWidgetPredicate(
// (Widget widget) => widget is Text && (Widget widget) => widget is Text &&
// widget.data.startsWith('Running on:'), widget.data!.startsWith('Running on:'),
// ), ),
// findsOneWidget, findsOneWidget,
// ); );
// }); });
// } }

View File

@ -70,11 +70,11 @@ class Mop {
/// [disablePermission] is optional. /// [disablePermission] is optional.
/// ///
Future<Map> initialize(String appkey, String secret, Future<Map> initialize(String appkey, String secret,
{required String apiServer, { String? apiServer,
required String apiPrefix, String? apiPrefix,
required String cryptType, String? cryptType,
required bool disablePermission, bool? disablePermission,
required String userId, String? userId,
bool encryptServerData = false, bool encryptServerData = false,
bool debug = false}) async { bool debug = false}) async {
final Map ret = await _channel.invokeMethod('initialize', { final Map ret = await _channel.invokeMethod('initialize', {
@ -103,26 +103,26 @@ class Mop {
/// [cryptType] is optional. cryptType, should be MD5/SM /// [cryptType] is optional. cryptType, should be MD5/SM
Future<Map> openApplet( Future<Map> openApplet(
final String appId, { final String appId, {
required final String path, final String? path,
required final String query, final String? query,
required final int sequence, final int? sequence,
required final String apiServer, final String? apiServer,
required final String apiPrefix, final String? apiPrefix,
required final String fingerprint, final String? fingerprint,
required final String cryptType, final String? cryptType,
required final String scene, final String? scene,
}) async { }) async {
Map<String, Object> params = {'appId': appId}; Map<String, Object> params = {'appId': appId};
Map param = {}; Map param = {};
param["path"] = path; param["path"] = path;
param["query"] = query; param["query"] = query;
if (param.length > 0) params["params"] = param; if (param.length > 0) params["params"] = param;
params["sequence"] = sequence; if (sequence != null) params["sequence"] = sequence;
params["apiServer"] = apiServer; if (apiServer != null) params["apiServer"] = apiServer;
params["apiPrefix"] = apiPrefix; if (apiPrefix != null) params["apiPrefix"] = apiPrefix;
params["fingerprint"] = fingerprint; if (fingerprint != null) params["fingerprint"] = fingerprint;
params["cryptType"] = cryptType; if (cryptType != null) params["cryptType"] = cryptType;
param["scene"] = scene; if (scene != null) param["scene"] = scene;
final Map ret = await _channel.invokeMethod('openApplet', params); final Map ret = await _channel.invokeMethod('openApplet', params);
return ret; return ret;
} }