并非所有图像都可以显示

问题描述 投票:0回答:1

The image with the title Surya 16, La bold and the egg image can be displayed while package A cannot

这是我获取图像的代码

Image.network('http://10.0.2.2:8000/${widget.product.imageUrl}',               fit: BoxFit.cover),

和错误,


════════ Exception caught by image resource service ════════════════════════════
The following HttpException was thrown resolving an image codec:
Connection closed while receiving data, uri = http://10.0.2.2:8000/uploads/products/0-1713659504.png

When the exception was thrown, this was the stack:
#0      \_HttpIncoming.listen.\<anonymous closure\> (dart:\_http/http_impl.dart:442:7)
http_impl.dart:442
#11     \_HttpParser.\_reportBodyError (dart:\_http/http_parser.dart:1201:22)
http_parser.dart:1201
#12     \_HttpParser.\_onDone (dart:\_http/http_parser.dart:899:9)
http_parser.dart:899
#20     \_Socket.\_onData (dart:io-patch/socket_patch.dart:2454:21)
socket_patch.dart:2454
#27     new \_RawSocket.\<anonymous closure\> (dart:io-patch/socket_patch.dart:1943:35)
socket_patch.dart:1943
#28     \_NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1372:18)
socket_patch.dart:1372
(elided 25 frames from dart:async)

Image provider: NetworkImage("http://10.0.2.2:8000/uploads/products/0-1713659504.png", scale: 1.0)
Image key: NetworkImage("http://10.0.2.2:8000/uploads/products/0-1713659504.png", scale: 1.0)

我尝试使用这个但没有成功

CachedNetworkImage(imageUrl: 'http://10.0.2.2:8000/${image['image']}',   placeholder: (context, url) => CircularProgressIndicator(), // Tampilkan indicator loading   errorWidget: (context, url, error) => Icon(Icons.error), ),

如何解决这个问题?

flutter image api http flutter-image
1个回答
0
投票

检查您是否开启内网权限。

前往

android/app/src/main/AndroidManifest.xml

并检查你是否有这行代码:

<uses-permission android:name="android.permission.INTERNET" /> 

编码快乐:)

© www.soinside.com 2019 - 2024. All rights reserved.