primaryController property

  1. @override
BccmPlayerController get primaryController
override

Implementation

@override
get primaryController {
  if (_primaryController != null) {
    return _primaryController!;
  } else {
    final controller = BccmPlayerController.empty();
    _removePrimaryPlayerListener = BccmPlayerInterface.instance.stateNotifier.addListener((state) {
      if (state.primaryPlayerId != controller.value.playerId) {
        final id = state.primaryPlayerId;
        if (id != null) {
          final notifier = BccmPlayerInterface.instance.stateNotifier.getPlayerNotifier(id);
          assert(notifier != null, 'Something went wrong. Primary player should always have a notifier.');
          if (notifier != null) {
            // ignore: invalid_use_of_protected_member
            controller.swapPlayerNotifier(notifier);
          }
        }
      }
    }, fireImmediately: true);
    return _primaryController = controller;
  }
}