invalid_ deprecated_ optional_ annotation
Details about the 'invalid_deprecated_optional_annotation' diagnostic produced by the Dart analyzer.
The annotation '@Deprecated.optional' can only be applied to optional parameters.
Description
#
The analyzer produces this diagnostic when the
@Deprecated.optional
annotation is applied to a parameter that isn't an optional
parameter. The annotation must not be used on a parameter in a
local function, an anonymous function, a function-typed
parameter, or a typedef. It is only valid on optional
parameters in a top-level function, a method, or a
constructor.
Example
#The following code produces this diagnostic because the annotation is on a required parameter:
void f(@Deprecated.optional() int p) {}
Common fixes
#Remove the annotation:
void f(int p) {}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.