How do I create a file in a directory structure that does not exist yet in Dart?

Alternatively:

new File('path/to/file').create(recursive: true);

Or:

new File('path/to/file').create(recursive: true)
.then((File file) {
  // Stuff to do after file has been created...
});

Recursive means that if the file or path doesn’t exist, then it will be created. See: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-io.File#id_create

EDIT: This way new Directory doesn’t need to be called! You can also do this in a synchronous way if you so choose:

new File('path/to/file').createSync(recursive: true);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)