-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get 请求怎么读取图片 #210
Comments
2.x中 Response<ResponseBody> rs = await Dio().get<ResponseBody>(
'https://admin-test.shiguangkey.com/captcha.jpg',
options: Options(
responseType: ResponseType.stream,
),
);
print(rs.data.stream ); 另外,你也可以通过设置 Response<List<int>> rs = await Dio().get<List<int>>(
'https://admin-test.shiguangkey.com/captcha.jpg',
options: Options(
responseType: ResponseType.bytes,
),
);
print(rs.data); |
谢谢!建议更新 readme 文档。 |
@wendux 你好!目前有一个需求是使用dio来获取一张图片,该图片资源在https下,由于根证书的问题需要跳过https校验。如何在利用dio跳过证书校验的同时,将response转为ImageProvider或者Image(利用getImage代替NetworkImage)? 部分代码如下: image: new DecorationImage(
image: new NetworkImage(thumbImgUrl),
fit: BoxFit.cover
) static Future<Stream> getImage(String url) async {
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
};
Response response = await dio.get(
url,
options: Options(responseType: ResponseType.stream)
);
return response.data.stream;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
尝试 get 请求图片。
Steps to Reproduce
使用泛型
Logs
type 'ResponseBody' is not a subtype of type 'HttpClientResponse'
The text was updated successfully, but these errors were encountered: