computeFileHash method

  1. @override
Stream<FileHashProgress> computeFileHash(
  1. String filePath
)
override

Computes SHA256 hash of a file by reading it in chunks Returns stream updates with progress and a final event containing FileHashProgress.hash

Implementation

@override
Stream<FileHashProgress> computeFileHash(String filePath) async* {
  final file = File(filePath);
  if (!await file.exists()) {
    throw PathNotFoundException(
      'Cannot open file',
      OSError('No such file or directory', 2),
      filePath,
    );
  }

  yield* IsolateManager.instance
      .runInComputeIsolateStream<String, FileHashProgress>(
        _computeFileHashTask,
        filePath,
      );
}