JS class

An annotation on a JavaScript interop declaration.

This annotation defines a given library, top-level external declaration, or extension type as a JavaScript interop declaration.

Specifying name customizes the JavaScript name to use, which can be used in the following scenarios:

  • Adding a JavaScript prefix to all the external top-level declarations, static members, and constructors of a library by parameterizing the annotation on the library with name.
  • Specifying the JavaScript class to use for external static members and constructors of an interop extension type by parameterizing the annotation on the interop extension type with name.
  • Renaming external declarations by parameterizing the annotation on the member with name.

In the case where name is not specified, the Dart name of the extension type or external declaration is used as the default.

See https://dart.dev/interop/js-interop/usage#js for more details on how to use this annotation.

Note

package:js exports an @JS annotation as well. Unlike that annotation, this annotation applies to extension types, and will result in more type-checking for external top-level declarations.

Constructors

JS([String? name])
const

Properties

hashCode int
The hash code for this object.
no setterinherited
name String?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

Operators

operator ==(Object other) bool
The equality operator.
inherited