deprecated-member-use-from-same-package
Same as deprecated_member_use_from_same_package in Dart lints
- Group
- Correctness
- Path
lint/correctness/deprecated-member-use-from-same-package- Default
- Off, opt in
- Origin
- Dart lints
- Rule
- 217 of 512
Reports uses of deprecated declarations from their own package.
Canonical project identities and lexical scopes prove code and documentation
references; unknown receivers and ambiguous imports remain silent. Deprecated
declarations and libraries form a usage frontier, so their bodies, documentation,
and metadata are exempt, including part files of deprecated libraries. Library
directive messages use canonical package URIs, and local functions stay within
their lexical block, switch case, or unbraced statement body. Deprecation messages
are trimmed and punctuated like the analyzer's messages. Membership is cached per source.
Cascade diagnostics consume shared semantic traversal callbacks, including
receiver inference and indexed-assignment classification.
Extension owners honor inferred arguments and bounds; super owners follow
concrete mixin constraints before interface contracts. Optional parameter
deprecations are checked even when the enclosing member is not deprecated.
Explicit construction resolves dotted constructor selectors separately from
import prefixes; generic class qualifiers retain their constructor metadata.
Constructor aliases resolve to the underlying declaration before constructor
and deprecated-parameter metadata is inspected. Compound assignments and
increments inspect both accessors, while simple assignments inspect only setters.
Local metadata follows binding declaration identities, including loop variables;
local function metadata also applies to references before its lexical declaration.
Enum constants do not name deprecated constructors; implicit extension operators
use the same applicable-extension lookup as ordinary members.
Member and parameter selectors borrow names and keep declaration kind, access,
and static dispatch distinct; retained metadata owns names only during indexing.
Grouped references are visited, but grouped callees do not expose declaration
parameter metadata as direct invocations do.
Null-shortened receiver chains recover reached declaration types until parentheses,
preserving declared nullable members and applicable nullable extensions.
Named constructor uses cover their full qualifier; implicit super uses cover
the complete constructor declaration that makes the implicit call.
Invalid
@deprecated
void oldFunction() {}
@Deprecated('Use `newValue`.')
int oldValue = 1;
@Deprecated('Use `NewType`.')
class Legacy {}
class Api {
Api();
@deprecated
Api.old();
@deprecated
void oldMethod() {}
}
void use(Api value) {
oldFunction();
print(oldValue);
oldValue = 2;
Legacy? variable;
Api.old();
value.oldMethod();
}
class Properties {
@deprecated
int oldField = 0;
@deprecated
int get oldGetter => 0;
@deprecated
set oldSetter(int value) {}
}
class InheritedProperties extends Properties {}
void propertyUses(InheritedProperties value) {
print(value.oldField);
print(value.oldGetter);
}
class GlobalUses {
void call() {
oldFunction();
}
}
/// [oldFunction]
void linkedFunction() {}
/// [Properties.oldGetter]
void linkedGetter() {}
class LinkedProperties extends Properties {
/// [oldField]
void linkedMember() {}
}
enum OldChoice {
@deprecated
old,
current;
}
void patternUse(OldChoice value) {
switch (value) {
case OldChoice.old:
break;
case OldChoice.current:
break;
}
}void use(Api value) { oldFunction(); oldFunction(); print(oldValue); print(oldValue); oldValue = 2; oldValue = 2; Legacy? variable; Legacy? variable; Api.old(); Api.old(); value.oldMethod();void propertyUses(InheritedProperties value) { print(value.oldField); print(value.oldField); print(value.oldGetter); void call() { oldFunction();}/// [oldFunction]void linkedFunction() {}/// [Properties.oldGetter]class LinkedProperties extends Properties { /// [oldField] switch (value) { case OldChoice.old:Valid
@deprecated
void oldFunction() { oldFunction(); }
void shadow(void Function() oldFunction) { oldFunction(); }
void localShadow() { void oldFunction() {} oldFunction(); }
void unknown(dynamic value) { value.oldMethod(); }
void freshFunction() {}
void fresh() { freshFunction(); }
@Deprecated('Use freshFunction')
void exempt() { oldFunction(); }
void requiredNamed({@deprecated required int value}) {}
class RequiredNamedConstructor {
RequiredNamedConstructor({@Deprecated('Still required') required int value});
}
void requiredNamedUses() {
requiredNamed(value: 1);
RequiredNamedConstructor(value: 1);
}
class DocumentationShadow {
@deprecated
void oldMethod() {}
/// [oldMethod] is the parameter, not the deprecated member.
void accept(void Function() oldMethod) {}
}
/// [oldFunction] is the parameter, not the deprecated top-level declaration.
void documentedParameter(void Function() oldFunction) {}Configure deprecated-member-use-from-same-package
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"correctness": {
"deprecated-member-use-from-same-package": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/correctness/deprecated-member-use-from-same-package: <reason>More correctness rules
- diagnostic-describe-all-properties
diagnostic_describe_all_propertiesflutterRequires every public property of a
Diagnosticableclass to be referenced in its debug methods. - discarded-futures
discarded_futuresDon't discard
Futures returned by calls in synchronous functions. - dispose-fieldsrecommendedflutter
Requires other owned disposable State fields to be released in
dispose(). - dispose-focus-node-and-timerrecommendedflutter
Requires owned
FocusNodeand Timer fields to be released inState.dispose(). - dispose-provided-instancesrecommendedriverpod
Flags provider-created instances with a dispose method that lack ref.onDispose cleanup.
- dispose-provider-resourcesrecommendedriverpod
Flags provider-created resources without autoDispose or ref.onDispose cleanup.
- dispose-providersrecommendedprovider
Requires cleanup callbacks for disposable values created by package:provider's Provider.
- emit-new-bloc-state-instancesrecommendedbloc
Flags Bloc and Cubit emissions that reuse their current state instance.