update init 方法

master
wanghualei 2021-06-19 13:39:56 +08:00
parent 398b697084
commit 6fe2ed0cec
1 changed files with 17 additions and 2 deletions

View File

@ -9,6 +9,19 @@ typedef MopEventErrorCallback = void Function(dynamic event);
typedef ExtensionApiHandler = Future Function(dynamic params);
class ServerConfig {
String appkey;
String secret;
String apiServer;
String apiPrefix;
String cryptType;
ServerConfig(this.appkey, this.secret, this.apiServer, this.apiPrefix, this.cryptType);
Map<String, dynamic> toJson() =>
{'appkey': appkey, 'secret': secret, 'apiServer': apiServer, 'apiPrefix': apiPrefix, 'cryptType':cryptType};
}
class Mop {
static final Mop _instance = new Mop._internal();
MethodChannel _channel;
@ -74,7 +87,8 @@ class Mop {
String apiPrefix,
String cryptType,
bool disablePermission,
String userId}) async {
String userId,
List<ServerConfig> serverConfigs}) async {
final Map ret = await _channel.invokeMethod('initialize', {
'appkey': appkey,
'secret': secret,
@ -82,7 +96,8 @@ class Mop {
'apiPrefix': apiPrefix,
'cryptType': cryptType,
'disablePermission': disablePermission,
'userId': userId
'userId': userId,
'serverConfigs',serverConfigs.map((e) => e.toJson())
});
return ret;
}