How to take a screenshot of a widget in Flutter web?
There is RenderRepaintBoundary Widget which can be used for Mobile and iOS but It is giving error for Web.
How to take a screenshot of a widget in Flutter web?
There is RenderRepaintBoundary Widget which can be used for Mobile and iOS but It is giving error for Web.
Firstly, import:
import 'dart:html';
import 'package:screenshot/screenshot.dart';
Then, it's as easy as:
screenshotController.capture().then((Uint8List? value) {
final _base64 = base64Encode(value!);
final anchor =
AnchorElement(href: 'data:application/octet-stream;base64,$_base64')
..download = "image.png"
..target = 'blank';
document.body!.append(anchor);
anchor.click();
anchor.remove();
});
There you go - saving / downloading an image using flutter web!
You can use it as usual if you set the --web-renderer canvaskit flag when building/running your web app.