createTempSync method
Synchronously creates a temporary directory in this directory.
Additional random characters are appended to prefix
to produce
a unique directory name. If prefix
is missing or null, the empty
string is used as prefix
.
Returns the newly created temporary directory.
Implementation
@override
file.Directory createTempSync([String? prefix]) {
prefix ??= '';
if (path == '') {
throw ArgumentError('Directory.createTemp called with an empty path. '
'To use the system temp directory, use Directory.systemTemp');
}
String fullPrefix;
if (path.endsWith('/') || (Platform.isWindows && path.endsWith('\\'))) {
fullPrefix = '$path$prefix';
} else {
fullPrefix = '$path${Platform.pathSeparator}$prefix';
}
final resultPath = fs.mkdtempSync(fullPrefix);
return Directory(resultPath);
}