checkNotNull<T> method

  1. @Since("2.1")
T checkNotNull <T>(
  1. T? argument,
  2. [String? name]
)
@Since("2.1")

Throws 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

@Since("2.1")
static T checkNotNull<@Since("2.8") T>(T? argument, [String? name]) {
  if (argument == null) throw ArgumentError.notNull(name);
  return argument;
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-core/ArgumentError/checkNotNull.html