create method
Creates the directory if it doesn't exist.
If recursive
is false, only the last directory in the path is
created. If recursive
is true, all non-existing path components
are created. If the directory already exists nothing is done.
Returns a Future<Directory>
that completes with this
directory once it has been created. If the directory cannot be
created the future completes with an exception.
Implementation
@override
Future<Directory> create({bool recursive = false}) async {
if (await exists()) return this;
final completer = Completer<Directory>();
void callback(Object? err, [_]) {
if (err == null) {
completer.complete(this);
} else {
completer.completeError(err);
}
}
var jsCallback = js.allowInterop(callback);
fs.mkdir(path, MkdirOptions(recursive: recursive), jsCallback);
return completer.future;
}