getFile method
ReadProgress?
getFile(
- FileFormat? format,
- AsyncValueChanged<
DataReaderFile> onFile, { - ValueChanged<
Object> ? onError, - bool allowVirtualFiles = true,
- bool synthesizeFilesFromURIs = true,
override
Loads file for the given format.
If no file for given format is available, null
progress is returned and
the onFile
block will not be called.
Returned progress tracks the progress from method invocation to receiving the file object. To track progress of reading the file you can use reported file size in DataReaderFile when you read the stream.
On most platform the progress will be indeterminate followed by 1.0 at the end. On iOS the progress is bridged to underlying NSProgress object and should be more accurate and cancellable.
Implementation
@override
ReadProgress? getFile(
FileFormat? format,
AsyncValueChanged<DataReaderFile> onFile, {
ValueChanged<Object>? onError,
bool allowVirtualFiles = true,
bool synthesizeFilesFromURIs = true,
}) {
if (format == null) {
return null;
}
final item =
items.firstWhereOrNull((element) => element.canProvide(format));
if (item != null) {
return item.getFile(format, onFile,
onError: onError,
allowVirtualFiles: allowVirtualFiles,
synthesizeFilesFromURIs: synthesizeFilesFromURIs);
} else {
return null;
}
}