checkFileIsExist method

Future<void> checkFileIsExist(
  1. String file
)

Implementation

Future<void> checkFileIsExist(String file) async {
  try {
    String fullName = path.join('./lib/pages', selectModule, _snakeCase(file));
    bool isExist = await Directory(fullName).exists();

    if (isExist) {
      print('文件已存在,重新输入');
      await handleInputName();
    } else {
      print('页面中文注释:');
      String? answerComment = stdin.readLineSync();
      if (answerComment != null) {
        pageComment = answerComment;
        await handleWriteFolder(fullName, file);
      }
    }
  } catch (error) {
    print(error);
  }
}