writeFile function

Future<String> writeFile(
  1. String path
)

Implementation

Future<String> writeFile(String path) async {
  var file = Directory(path).absolute;
  var originPath = file.path;
  var destinationRootPath = originPath.replaceRange(
      originPath.lastIndexOf('/'), originPath.length, '/yingzi_ast/');

  var newDirectory = Directory(destinationRootPath);
  try {
    var exists = await newDirectory.exists();
    if (!exists) {
      await newDirectory.create();
    }
  } catch (e) {
    print(e);
  }
  return newDirectory.path;
}