isValid method

Future<bool> isValid(
  1. bool fromAppStartup
)

If the trigger is valid, based on the triggers method and all the triggers. @param fromAppStartup If the check has been triggered at startup. @returns If the trigger is valid.

Implementation

Future<bool> isValid(bool fromAppStartup) async {
  for (MBTrigger trigger in triggers) {
    bool triggerIsValid = await trigger.isValid(fromAppStartup);
    switch (method) {
      case MBMessageTriggersMethod.any:
        if (triggerIsValid) {
          return true;
        }
        break;
      case MBMessageTriggersMethod.all:
        if (!triggerIsValid) {
          return false;
        }
    }
  }
  return method == MBMessageTriggersMethod.any ? false : true;
}