Reputation: 305
Future<Uint8List> _loadNetworkImage(String imgname) async {
try {
final ByteData imageData = await NetworkAssetBundle(Uri.parse('https://picsum.photos/250?image=9')).load("");
final Uint8List bytes = imageData.buffer.asUint8List();
return bytes;
} catch (_) {
throw "Couldn't resolve network Image.";
}
}
when i run this code on flutter web i am getting this error i dont know why can anyone please help me.
Error: Couldn't resolve network Image.
Upvotes: 3
Views: 585
Reputation: 347
Uri uri = Uri.parse(filePath);
Uint8List fileData = await http.readBytes(uri);
Upvotes: 1