Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. Deprecated class
Deprecated
description

Deprecated class

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

The annotationdeprecated is a shorthand for deprecating untilan unspecified "next release" without migration instructions.

A feature can be any part of an API, from a full library to a singleparameter.

The intent of the@Deprecated annotation is to inform authorswho are currently using the feature,that they will soon need to stop using that feature in their code,even if the feature is currently still working correctly.

Deprecation is an early warning that the deprecated featureis scheduled to be removed at a later time,a time possibly specified inmessage.A deprecated feature should no longer be used,code using it will break at some point in the future.If existing code is using the feature,that code should be rewritten to no longer use the deprecated feature.

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

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

Deprecation applies transitively to parts of a deprecated feature:

  • 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.

If a feature is deprecated in a superclass, it isnot automaticallydeprecated in a subclass as well. It is reasonable to remove a memberfrom a superclass and retain it in a subclass, so it needs to be possibleto deprecate the member only in the superclass.

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 ofa non-deprecated library.
  • the code refers statically to a deprecated declaration.
  • the code uses a member of an object with a statically knowntype, where the member is deprecated on the interface of the static type.
  • the code calls a method with an argument where thecorresponding optional parameter is deprecated on the object's static type.

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

Constructors

Deprecated(String?message)
Creates a deprecation annotation which specifies the migration path andexpiration of the annotated feature.
const
Deprecated.extend([String?message])
Creates an annotation which deprecates extending a class.
const
Deprecated.implement([String?message])
Creates an annotation which deprecates implementing a class or mixin.
const
Deprecated.instantiate([String?message])
Creates an annotation which deprecates instantiating a class.
const
Deprecated.mixin([String?message])
Creates an annotation which deprecates mixing in a class.
const
Deprecated.optional([String?message])
Creates an annotation which deprecates omitting an argument for theannotated parameter.
const
Deprecated.subclass([String?message])
Creates an annotation which deprecates subclassing (implementing orextending) a class.
const

Properties

hashCodeint
The hash code for this object.
no setterinherited
messageString?
Message provided to the user when they use the deprecated feature.
final
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString()String
A string representation of this object.
override

Operators

operator ==(Objectother)bool
The equality operator.
inherited
  1. Dart
  2. dart:core
  3. Deprecated class
dart:core library

[8]ページ先頭

©2009-2025 Movatter.jp