diff --git a/lib/models/Site.dart b/lib/models/Site.dart index 46ee231..05efa36 100644 --- a/lib/models/Site.dart +++ b/lib/models/Site.dart @@ -93,20 +93,22 @@ class Site { this.rawConfig = rawConfig; this.lastManagedUpdate = lastManagedUpdate; - _updates = EventChannel('net.defined.nebula/$id'); - _updates.receiveBroadcastStream().listen((d) { - try { - _updateFromJson(d); - _change.add(null); - } catch (err) { - //TODO: handle the error - print(err); - } - }, onError: (err) { - _updateFromJson(err.details); - var error = err as PlatformException; - _change.addError(error.message ?? 'An unexpected error occurred'); - }); + if (id != null) { + _updates = EventChannel('net.defined.nebula/$id'); + _updates.receiveBroadcastStream().listen((d) { + try { + _updateFromJson(d); + _change.add(null); + } catch (err) { + //TODO: handle the error + print(err); + } + }, onError: (err) { + _updateFromJson(err.details); + var error = err as PlatformException; + _change.addError(error.message ?? 'An unexpected error occurred'); + }); + } } factory Site.fromJson(Map json) {