readInPlace static method
Read a file in place from the iCloud container using coordinated access.
relativePath is the path within the iCloud container.
Trailing slashes are rejected here because reads are file-centric and coordinated through UIDocument/NSDocument.
Coordinated access loads the full contents into memory. Text is decoded as UTF-8; use readInPlaceBytes for binary formats.
idleTimeouts configures the idle watchdog for downloads (defaults to
60s, 90s, 180s).
retryBackoff configures the retry delay between attempts (exponential
backoff by default).
Returns the file contents as a String.
Throws on file-not-found and other failures.
Note: the return type is nullable to match the platform interface, but
the native implementations only return null if a platform explicitly
chooses to.
Implementation
static Future<String?> readInPlace({
required String containerId,
required String relativePath,
List<Duration>? idleTimeouts,
List<Duration>? retryBackoff,
}) async {
// Reads are file-centric; reject directory paths.
if (relativePath.endsWith('/')) {
throw InvalidArgumentException('invalid relativePath: $relativePath');
}
if (relativePath.trim().isEmpty) {
throw InvalidArgumentException('invalid relativePath: $relativePath');
}
if (!_validateRelativePath(relativePath)) {
throw InvalidArgumentException('invalid relativePath: $relativePath');
}
return ICloudStoragePlatform.instance.readInPlace(
containerId: containerId,
relativePath: relativePath,
idleTimeouts: idleTimeouts,
retryBackoff: retryBackoff,
);
}