DartCallback class

Registers a Dart callback, which can be called from the Javascript side. This will be turned into a platform-specific dart callback, on runtime.

Usage:

WebViewX(
  ...
  dartCallbacks: {
    DartCallback(
      name: 'Unique_Name_Here',
      callBack: (message) => print(message),
    ),
  },
  ...
),

And then, from the Javascript side, when you need to call back Dart from JS:

Calling Dart from JS, on Web:

Unique_Name_Here('test');

Calling Dart from JS, on Mobile:

Unique_Name_Here.postMessage('test');

For more about the Web and Mobile different call types see EmbeddedJsContent

Constructors

DartCallback({required String name, required dynamic callBack(dynamic message)})
Constructor
const

Properties

callBack → dynamic Function(dynamic message)
Callback function
final
hashCode int
The hash code for this object.
no setteroverride
name String
Callback's name
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.
override