saveTo method
Saves the file to the specified path. Efficiently moves the temp file if available, otherwise writes bytes.
Implementation
Future<String> saveTo(String path) async {
if (_tempFilePath != null) {
final tempFile = File(_tempFilePath);
if (await tempFile.exists()) {
await tempFile.rename(path);
return path;
}
}
final file = File(path);
await file.writeAsBytes(data);
return file.path;
}