ArgumentError constructor

ArgumentError([
  1. dynamic message,
  2. @Since("2.14") String? name
])

Creates an error with message describing the problem with an argument.

Existing code may be using message to hold the invalid value. If the message is not a String, it is assumed to be a value instead of a message.

If name is provided, it should be the name of the parameter which received an invalid argument.

Prefer using ArgumentError.value instead to retain and document the invalid value as well.

Implementation

@pragma("vm:entry-point")
ArgumentError([this.message, @Since("2.14") this.name])
  : invalidValue = null,
    _hasValue = false;