i am working on a program with flutter desktop, that screenshots a widget, and saves it to the desktop. i have been able to take the screenshot, my issue is how to save the screenshot to my desktop using path_provider package
Here is a code i wrote to get the path
Future<String> getFilePath() async {
Directory appDocumentsDirectory =
await getApplicationDocumentsDirectory(); // 1
String appDocumentsPath = appDocumentsDirectory.path; // 2
String filePath = '$appDocumentsPath/image.png'; // 3
return filePath;
}
Here is a code for the screenshot logic, i wrapped my main code in a Screenshot widget
ElevatedButton(
onPressed: () {
screenshotController
.capture(delay: Duration(milliseconds: 10))
.then((capturedImage) async {
ShowCapturedWidget(context, capturedImage!);
}).catchError((onError) {
print(onError);
});
},
child: Text(_message)),
],
),
),
),
);
}
Future<dynamic> ShowCapturedWidget(
BuildContext context, Uint8List capturedImage) {
return showDialog(
useSafeArea: false,
context: context,
builder: (context) => Scaffold(
appBar: AppBar(
title: Text("Captured widget screenshot"),
),
body: Center(
child: capturedImage != null
? Image.memory(capturedImage)
: Container()),
),
);
}
How do i save the capturedImage to my desktop, or how do i send it automatically as a mail.