rename static method

bool rename(
  1. File? file,
  2. String newName
)

Implementation

static bool rename(File? file, String newName) {
  if (file == null) return false;
  if (!file.existsSync()) return false;
  if (newName.isEmpty) return false;
  if (newName == path.basename(file.path)) return true;

  final newPath = path.join(path.dirname(file.path), newName);
  try {
    file.renameSync(newPath);
    return true;
  } catch (e) {
    return false;
  }
}