getWatchRegionStream method
The function returns a stream of Region objects received from a broadcast stream. @returns The method is returning a Stream of Region objects.
Implementation
@override
Stream<Region>? getWatchRegionStream() {
if (_regionStream == null) {
_regionStream = _regionStreamController.stream;
_regionEventChannel
.receiveBroadcastStream("region")
.map<String>((dynamic event) {
return event as String;
}).listen((regionString) {
Map<String, dynamic> data = jsonDecode(regionString);
Region region = Region.jsonToObj(data);
_regionStreamController.add(region);
});
}
return _regionStream;
}