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;
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。