The annotation @Deprecated('expires when') marks a feature as deprecated.

The annotation @deprecated is a shorthand for deprecating until an unspecified "next release".

The intent of the @Deprecated annotation is to inform users of a feature that they should change their code, even if it is currently still working correctly.

A deprecated feature is scheduled to be removed at a later time, possibly specified as the "expires" field of the annotation. This means that a deprecated feature should not be used, or code using it will break at some point in the future. If there is code using the feature, that code should be rewritten to not use the deprecated feature.

A deprecated feature should document how the same effect can be achieved, so the programmer knows how to rewrite the code.

The @Deprecated annotation applies to libraries, top-level declarations (variables, getters, setters, functions, classes and typedefs), class-level declarations (variables, getters, setters, methods, operators or constructors, whether static or not), named optional arguments and trailing optional positional parameters.

Deprecation is transitive:

  • If a library is deprecated, so is every member of it.
  • If a class is deprecated, so is every member of it.
  • If a variable is deprecated, so are its implicit getter and setter.

A tool that processes Dart source code may report when:

  • the code imports a deprecated library.
  • the code exports a deprecated library, or any deprecated member of  a non-deprecated library.
  • the code refers statically to a deprecated declaration.
  • the code dynamically uses a member of an object with a statically known type, where the member is deprecated on the static type of the object.
  • the code dynamically calls a method with an argument where the corresponding optional parameter is deprecated on the object's static type.

If the deprecated use is inside a library, class or method which is itself deprecated, the tool should not bother the user about it. A deprecated feature is expected to use other deprecated features.

Constructors

Deprecated(String expires)

Create a deprecation annotation which specifies the expiration of the annotated feature.

const

Properties

expires String

A description of when the deprecated feature is expected to be retired.

read-only
hashCode int

Get a hash code for this object.

read-only, inherited
runtimeType Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) bool

The equality operator.

inherited

Methods

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
toString() String

Returns a string representation of this object.