[bug[ Check for already existing files and folder before rename.

Fixes #2560 

First, the formatting: I'd reformat as:
```dart
       Iterable<String> childNames = resource.parent == 
         null ? [] : resource.parent.getChildren().map((resource) => resource.name);
```
In general, try to avoid splitting `?:` around the `:`. And even if you split an expression around an operator, leave the operator on the first line, not the second (per the Style Guide).