fetchContents method

Stream<ShareItemChunk>? fetchContents(
  1. String uri, [
  2. int? chunkSize
])
inherited

Implementation

Stream<ShareItemChunk>? fetchContents(String uri, [int? chunkSize]) {
  if (_fileContentStreamControllers.containsKey(uri)) {
    return null;
  }

  StreamController<ShareItemChunk> ctrl = StreamController(
    onListen: () {
      Map<String, dynamic> args = {
        "uri": uri,
        "chunkSize": chunkSize ?? 10 * 1024 * 1024,
      };
      _methodChannel.invokeMethod("fetchContents", args);
    },
    onCancel: () {
      _fileContentStreamControllers[uri]?.sink.close();
      _fileContentStreamControllers.remove(uri);
    },
  );
  _fileContentStreamControllers[uri] = ctrl;

  return ctrl.stream;
}