Skip to content

Commit

Permalink
Update ns_input_stream.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Sep 27, 2024
1 parent d40f878 commit a0b5769
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkgs/objective_c/lib/src/ns_input_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ extension NSInputStreamStreamExtension on Stream<List<int>> {
DartInputStreamAdapter.inputStreamWithPort_(port.sendPort.nativePort);
late final StreamSubscription<dynamic> dataSubscription;

print('Here1');
dataSubscription = listen((data) {
if (inputStream.addData_(data.toNSData()) > maxReadAheadSize) {
print('pause');
dataSubscription.pause();
}
}, onError: (Object e) {
print('error');
final d = NSMutableDictionary.new1();
d.setObject_forKey_(e.toString().toNSString(), NSLocalizedDescriptionKey);
inputStream.setError_(NSError.errorWithDomain_code_userInfo_(
Expand All @@ -37,6 +40,7 @@ extension NSInputStreamStreamExtension on Stream<List<int>> {

dataSubscription.pause();
port.listen((count) {
print('count: $count');
// -1 indicates that the `NSInputStream` is closed. All other values
// indicate that the `NSInputStream` needs more data.
if (count == -1) {
Expand Down

0 comments on commit a0b5769

Please sign in to comment.