saveScreenshotPlatform function

Future<void> saveScreenshotPlatform(
  1. Uint8List uInt8List, {
  2. String imageType = 'image/png',
  3. double imageQuality = 0.95,
  4. String name = 'screenshot',
})

Implementation

Future<void> saveScreenshotPlatform(
  Uint8List uInt8List, {
  String imageType = 'image/png',
  double imageQuality = 0.95,
  String name = 'screenshot',
}) async {
  try {
    Directory root = await getTemporaryDirectory();
    String directoryPath = '${root.path}/appName';
    // Create the directory if it doesn't exist
    await Directory(directoryPath).create(recursive: true);
    String filePath = '$directoryPath/$name.jpg';
    await File(filePath).writeAsBytes(uInt8List);
  } catch (e) {
    // debugPrint(e.toString());
  }
}