captureAndShare method
Captures the wrapped widget as a PNG image and opens the platform share sheet.
fileName specifies the temporary file name used for saving and sharing the captured image.
Implementation
Future<void> captureAndShare({String fileName = 'widget_shot.png'}) async {
final bytes = await capture();
if (bytes == null) return;
final tempDir = await getTemporaryDirectory();
final filePath = '${tempDir.path}/$fileName';
final file = File(filePath)..writeAsBytesSync(bytes);
await SharePlus.instance.share(
ShareParams(text: 'Check out this widget!', files: [XFile(file.path)]),
);
}