Unhandled Exception: FileSystemException: Cannot retrieve length of file in flutter

Viewed 596

When I try to rename a File it throws a FileSystemException. This is the exception:

E/flutter (12252): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FileSystemException: Cannot retrieve length of file, path = '' (OS Error: No such file or directory, errno = 2)

This is the code:

for (String path in _files.paths) {
  for (File file in _pickedFiles) {
    if(file.path == path) {
      await _pickedFiles.last.rename(_path.withoutExtension(file.path) + '()' + _path.extension(file.path));
    }
  }
}
0 Answers
Related