Response response = await Dio().post(
'https://.........................',
data: formData, //create a Stream>
options: Options(
headers: {
'App-Key': '...........',
'Nonce': randNum,
'Timestamp': intDateTime,
'Signature': sha1.convert(bytes),
},
),
);
在用了dio()发送请求获取token后,leancloud的邮箱登录
LCUser user = await LCUser.loginByEmail(emailController.text, passwordController.text);
就用不了了。会报以下错误:
E/flutter (17363): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: Class 'DioError' has no instance getter 'code'.
E/flutter (17363): Receiver: Instance of 'DioError'
E/flutter (17363): Tried calling: code.

打印异常信息e.message显示I/flutter (17363): type '_ContentType' is not a subtype of type 'String'
究竟是什么问题一直好好的只要一用dio就不行..

问题解决了换成了http插件就好了。然后报头header里改成tostring,问题删不了所以就这样吧。

请升级到 0.5.0

有个插件叫http不叫dio,换一下就好了

我没有引入这两个插件中的任何一个。

确认下您用的是最新版吗(当前最新版是 0.5.0)

是的,0.5.0。该问题已解决,需在AndroidManifest.xml中添加<uses-permission android:name="android.permission.INTERNET"/>,我之前疏忽了。不过你们可以考虑把这一点假如到帮助文档里,谢谢!

非常感谢反馈文档的问题。当前文档只在即时通讯部分提了权限,实际上数据存储 Flutter SDK 同样需要设置 Android 权限。我们会尽快改进文档。