readInPlaceBytes method
Future<Uint8List?>
readInPlaceBytes({
- required String containerId,
- required String relativePath,
- List<
Duration> ? idleTimeouts, - List<
Duration> ? retryBackoff,
override
Read a file in place as bytes from the iCloud container using coordinated access.
containerId is the iCloud Container Id.
relativePath is the relative path to the file inside the container.
Trailing slashes are rejected here because reads are file-centric.
Returns the file contents as bytes. Coordinated access uses UIDocument/NSDocument and loads the full contents into memory. Use for small files.
idleTimeouts controls idle watchdog timeouts between retries.
retryBackoff controls retry delays between attempts.
Throws on file-not-found and other failures.
Implementation
@override
Future<Uint8List?> readInPlaceBytes({
required String containerId,
required String relativePath,
List<Duration>? idleTimeouts,
List<Duration>? retryBackoff,
}) async {
final result = await methodChannel.invokeMethod<Uint8List>(
'readInPlaceBytes',
{
'containerId': containerId,
'relativePath': relativePath,
// Send integer seconds; sub-second precision is intentionally ignored.
if (idleTimeouts != null)
'idleTimeoutSeconds': idleTimeouts
.map((duration) => duration.inSeconds)
.toList(growable: false),
if (retryBackoff != null)
'retryBackoffSeconds': retryBackoff
.map((duration) => duration.inSeconds)
.toList(growable: false),
},
);
return result;
}