From 34e066b820cdf743531c80b078a93e70edba31d5 Mon Sep 17 00:00:00 2001 From: FaFre Date: Thu, 15 Jul 2021 00:48:03 +0700 Subject: [PATCH 1/2] fixed awaits for stream --- lib/src/geojson.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/geojson.dart b/lib/src/geojson.dart index adec570..b05173a 100644 --- a/lib/src/geojson.dart +++ b/lib/src/geojson.dart @@ -175,8 +175,9 @@ class GeoJson { print("Processing"); _processFeatures(dataToProcess: dataToProcess, sink: _feats.sink); print("Closing"); + + await _feats.close(); await _sub.cancel(); - unawaited(_feats.close()); } Future _parse( From 7f0e305450014e264f6d0f5bf5b1a62501afc6c2 Mon Sep 17 00:00:00 2001 From: FaFre Date: Thu, 15 Jul 2021 00:48:28 +0700 Subject: [PATCH 2/2] wrapped debug prints in verbose --- lib/src/geojson.dart | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/src/geojson.dart b/lib/src/geojson.dart index b05173a..157dec7 100644 --- a/lib/src/geojson.dart +++ b/lib/src/geojson.dart @@ -169,12 +169,19 @@ class GeoJson { data: data, nameProperty: nameProperty, verbose: verbose, query: query); final _feats = StreamController?>(); final _sub = _feats.stream.listen((f) { - print("FEAT SUB $f / ${f!.type}"); - _pipeFeature(f, disableStream: disableStream); + if (verbose) { + print("FEAT SUB $f / ${f!.type}"); + } + + _pipeFeature(f!, disableStream: disableStream); }); - print("Processing"); + if (verbose) { + print("Processing"); + } _processFeatures(dataToProcess: dataToProcess, sink: _feats.sink); - print("Closing"); + if (verbose) { + print("Closing"); + } await _feats.close(); await _sub.cancel(); @@ -548,7 +555,9 @@ class GeoJson { if (iso != null) { iso.send(feature); } else { - print("FEAT SINK $feature / ${feature?.type}"); + if (verbose) { + print("FEAT SINK $feature / ${feature?.type}"); + } sink?.add(feature); } if (verbose == true) {