checkNotNull<T> function

T checkNotNull<T>(
  1. T argument, [
  2. String? message
])

Throws IllegalStateException if argument is null. If name is supplied, it is used as the parameter name in the error message. Returns the argument if it is not null.

Implementation

T checkNotNull<T>(T argument, [String? message]) =>
    argument ??
    (throw IllegalStateException(message ?? 'Argument cannot be null'));