getPath function Null safety Utils

Future<String> getPath(
  1. String path
)

Prepends the application documents directory to path

Takes path which is the path you want to use inside your applications document directory. Returns the whole path starting with applications document directory with path appended to it.

Implementation

Future<String> getPath(String path) async {
  final applicationDirectoryPath =
      (await getApplicationDocumentsDirectory()).path;
  final wholePath = joinPath(applicationDirectoryPath, path);
  if (!Directory(wholePath).existsSync()) {
    Directory(wholePath).createSync();
  }
  return wholePath;
}