unpack method
Unpacks a resource saving it
to the file at pathTo
.
Implementation
void unpack(String pathTo) {
if (exists(pathTo) && !isFile(pathTo)) {
throw ResourceException('The unpack target $pathTo must be a file');
}
final normalized = normalize(pathTo);
if (!exists(dirname(normalized))) {
createDir(dirname(normalized), recursive: true);
}
// ignore: discarded_futures
final file = File(normalized).openSync(mode: FileMode.write);
try {
for (final line in content.split('\n')) {
if (line.trim().isNotEmpty) {
// ignore: discarded_futures
file.writeFromSync(base64.decode(line));
}
}
} finally {
file
..flushSync()
..closeSync();
}
}