I am trying to take a screenshot of a specific widget in Flutter (website development) but I am getting an exception:
'HtmlImage' can't be converted using toByteData
Is there any way to resolve the issue or take the screenshot in another way?
This method worked when I developed an android app.
Future<String> saveScreenshot(BuildContext context) async
{
// Get image
ui.Image renderedImage = await writeKey.currentState.rendered;
setState(() {image = renderedImage;});
// Encode image
ByteData byteData = image.buffer.toByteData(format: ui.ImageByteFormat.png); //Not working
var pngBytes = byteData.buffer.asUint8List();
// Create strings for message
String bs64 = base64Encode(pngBytes);
String size = bs64.length.toString();
// send image to server and get answer from it
var ans = await Network.communicate(bs64, size, context);
return ans;
}