addOnStateChangedListener method Null safety

StreamSubscription addOnStateChangedListener(
  1. dynamic onStateChanged(
    1. List<EmpireStateChanged> events
    )
)

Adds an event handler which gets executed each time an EmpireProperty value is changed.

If your listener references a BuildContext inside of a Widget, you should override the Widget dispose method and cancel the subscription.

Implementation

StreamSubscription addOnStateChangedListener(
    Function(List<EmpireStateChanged> events) onStateChanged) {
  final newSubscription = _stateController.stream.listen(onStateChanged);
  _subscriptions.add(newSubscription);
  return newSubscription;
}