winston Jeyaseelan
winston Jeyaseelan

Reputation: 305

Flutter web Error while loading network image url

 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

Answers (1)

krazy
krazy

Reputation: 347

Uri uri = Uri.parse(filePath);
Uint8List fileData = await http.readBytes(uri);

Upvotes: 1

Related Questions