getDirectory method Null safety

Directory getDirectory(
  1. Uri uri
)

Returns a Directory at uri, creates it recursively if it doesn't exist.

Implementation

Directory getDirectory(Uri uri) {
  final dir = Directory.fromUri(uri);
  if (!dir.existsSync()) {
    dir.createSync(recursive: true);
  }
  return dir;
}