throwIf function

void throwIf(
  1. bool condition,
  2. Object error
)

Two handy functions that help me to express my intention clearer and shorter to check for runtime errors

Implementation

// ignore: avoid_positional_boolean_parameters
void throwIf(bool condition, Object error) {
  if (condition) throw error;
}