unnecessary_question_mark
The '?' is unnecessary because '{0}' is nullable without it.
Description
#The analyzer produces this diagnostic when either the type dynamic
or the type Null
is followed by a question mark. Both of these types are inherently nullable so the question mark doesn't change the semantics.
Example
#The following code produces this diagnostic because the question mark following dynamic
isn't necessary:
dart
dynamic? x;
Common fixes
#Remove the unneeded question mark:
dart
dynamic x;
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.