length method

Future<int> length()

Returns the file length. If the file doesn't exist, or exists and is empty, returns 0.

Implementation

Future<int> length() async {
  _checkIfFileSystemIsTheSame();
  File file = _file ?? await this.file();

  if (!file.existsSync())
    return 0;
  else {
    try {
      return file.length();
    } catch (error) {
      if ((error is FileSystemException) && //
          error.message.contains("No such file or directory")) return 0;
      rethrow;
    }
  }
}