require function Null safety

void require(
  1. bool invariant,
  2. Exception exceptionFactory(
      )
    )

    Implementation

    void require(bool invariant, Exception Function() exceptionFactory) {
      if (!invariant) {
        throw exceptionFactory();
      }
    }