canSendEvent method

bool canSendEvent(
  1. String eventType
)

The level required to send a certain event. Defaults to 0 if there is no events_default set or there is no power level state in the room.

Implementation

bool canSendEvent(String eventType) {
  final powerLevelsMap = getState(EventTypes.RoomPowerLevels)?.content;
  if (powerLevelsMap == null) return 0 <= ownPowerLevel;
  final pl = powerLevelsMap
          .tryGetMap<String, Object?>('events')
          ?.tryGet<int>(eventType) ??
      powerLevelsMap.tryGet<int>('events_default') ??
      0;
  return ownPowerLevel >= pl;
}