ArgumentError constructor Null safety

  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 was invalid.

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


ArgumentError([this.message, @Since("2.14")])
    : invalidValue = null,
      _hasValue = false;