readFileStream method
Implementation
@override
Future<Stream<Uint8List>> readFileStream(
String uri, {
int? bufferSize,
int? start,
}) async {
// `readFileStream` on the native side now only opens the stream and
// registers it under `session` (see SafStreamPlugin.kt) -- a single
// MethodChannel call. Every chunk after that is pulled directly via JNI
// in SafStreamJniIo.readStream, with no EventChannel and no per-chunk
// BinaryMessenger round trip.
final session = _nextSession().toString();
final effectiveBufferSize = bufferSize ?? (4 * 1024 * 1024);
await methodChannel.invokeMethod<String>('readFileStream', {
'fileUri': uri.toString(),
'session': session,
'start': start,
});
return SafStreamJniIo.readStream(session, bufferSize: effectiveBufferSize);
}