Future<dynamic> _handleMethod(MethodCall call) async {
switch (call.method) {
case _METHOD_ONAUTHRESP:
_authRespStreamController.add(
WeiboAuthResp.fromJson(call.arguments as Map<String, dynamic>)); // 这里的实际类型不匹配导致报错
break;
case _METHOD_ONSHAREMSGRESP:
_shareMsgRespStreamController
.add(WeiboSdkResp.fromJson(call.arguments as Map<String, dynamic>));
break;
}
}
出现报错:_CastError (type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast)
通过iOS平台通道传递过来的数据类型不匹配导致错误而没有任何回调。正常情况下可以做如下修改来进行修复:
final Map<String, dynamic> json =
Map<String, dynamic>.from(call.arguments);
_authRespStreamController.add(WeiboAuthResp.fromJson(json));
但是由于作者引入了pedantic,会导致这个正常操作会静态分析报错The argument type 'dynamic' can't be assigned to the parameter type 'Map<dynamic, dynamic>'
当auth成功后,执行到
weibo.dart
的75行时出现报错:
_CastError (type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast)
通过iOS平台通道传递过来的数据类型不匹配导致错误而没有任何回调。正常情况下可以做如下修改来进行修复:但是由于作者引入了
pedantic
,会导致这个正常操作会静态分析报错The argument type 'dynamic' can't be assigned to the parameter type 'Map<dynamic, dynamic>'
希望能进行修复,谢谢~