deprecated_ optional
Details about the 'deprecated_optional' diagnostic produced by the Dart analyzer.
Omitting an argument for the '{0}' parameter is deprecated.
Description
#
The analyzer produces this diagnostic when an argument is
omitted for an optional parameter annotated with
@Deprecated.optional. This annotation indicates
that omitting an argument for the parameter is deprecated, and
the parameter will soon become required.
Example
#
Given a library p that defines a function with an
optional parameter annotated with
@Deprecated.optional:
void f({@Deprecated.optional() int a = 0}) {}
The following code produces this diagnostic, because the
invocation doesn't pass a value for the parameter
a:
import 'package:p/p.dart';
void g() {
f();
}
Common fixes
#
Follow any specific instructions provided in the
@Deprecated.optional
annotation.
If no instructions are present, pass an appropriate argument for the corresponding parameter:
import 'package:p/p.dart';
void g() {
f(a: 0);
}
Using the default value will preserve the current behavior of the code.
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.