JSExport class

Annotation to allow Dart classes to be wrapped with a JS object using dart:js_interop's createJSInteropWrapper.

When an instance of a class annotated with this annotation is passed to createJSInteropWrapper, the method returns a JS object that contains a property for each of the class' instance members. When called, these properties forward to the instance's corresponding members.

You can either annotate specific instance members to only wrap those members or you can annotate the entire class, which will include all of its instance members.

By default, the property will have the same name as the corresponding instance member. You can change the property name of a member in the JS object by providing a name in the @JSExport annotation on the member, like so:

class Export {
  @JSExport('printHelloWorld')
  void printMessage() => print('Hello World!');
}

which will then set the property 'printHelloWorld' in the JS object to forward to printMessage.

Classes and mixins in the hierarchy of the annotated class are included only if they are annotated as well or specific members in them are annotated. If a superclass does not have an annotation anywhere, its members are not included. If members are overridden, only the overriding member will be wrapped as long as it or its class has this annotation.

Only concrete instance members can and will be wrapped, and it's an error to annotate other members with this annotation.

Constructors

JSExport([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