RxReader / weibo_kit

Flutter版新浪微博登录/分享
Apache License 2.0
105 stars 33 forks source link

iOS平台auth出现无法正常使用问题 #28

Closed xx-li closed 3 years ago

xx-li commented 3 years ago

当auth成功后,执行到weibo.dart的75行时

  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>'

希望能进行修复,谢谢~

xx-li commented 3 years ago

测试用例中用json.decode()产生的数据类型是没问题的,所以测试用例能通过。 其它这样用的地方应该都有同样的问题~

xx-li commented 3 years ago

29