Bridge constructor

Bridge({
  1. Zebra123? listener,
})

Constructs a singleton instance of Bridge.

Bridge is designed to work as a singleton.

Implementation

// When a second instance is created, the first instance will not be able to listen to the
// EventChannel because it is overridden. Forcing the class to be a singleton class can prevent
// misuse of creating a second instance from a programmer.
factory Bridge({Zebra123? listener}) {
  _singleton ??= Bridge._();
  if (listener != null) {
    _singleton!.addListener(listener);
  }
  return _singleton!;
}