getFirstCustomRecordingFrame method
Implementation
Future<File> getFirstCustomRecordingFrame() async {
final List<Uint8List> frames = _customRecorderSubject.value;
if (frames.isEmpty) {
throw Exception('No custom recordings available to create a PNG.');
}
debugPrint('Number of frames: ${frames.length}');
// Create a temporary directory to store the frame
final directory = await getTemporaryDirectory();
final String tempDirPath = '${directory.path}/temp_frames';
await Directory(tempDirPath).create(recursive: true);
debugPrint('Temporary directory created: $tempDirPath');
// Write the first frame to a temporary file
final File frameFile = File('$tempDirPath/frame_0.png');
await frameFile.writeAsBytes(frames[0]);
debugPrint('Wrote first frame');
return frameFile;
}