My flutter app saves screenshots to disk (on Flutter desktop Mac and Windows). If writing fails due to whatever reason catch and error handling does not work. Statements after "catch" will never be executed despite debug output shows
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: FileSystemException: Cannot open file ...]
What am I missing here?
actual code snippet:
final dFile = File('$dPath(AS-Logo) $logoText.png');
screenshotController
.captureFromWidget(makeLogoShow(completeImageSize, logoText))
.then((capturedImage) {
try {
dFile.writeAsBytes(capturedImage);
} on FileSystemException catch (e) {
print("Error: $e");
return false;
}
});