createDartExport<T extends Object> function Null safety

Object createDartExport<T extends Object>(
  1. T dartObject

Given a Dart object that is marked exportable, creates a JS object literal that forwards to that Dart class. Look at the @JSExport annotation to determine what constitutes "exportable" for a Dart class. The object literal will be a map of export names (which are either the written instance member names or their rename) to their respective Dart instance members.

For example:

class ExportCounter {
  int value = 0;
  String stringify() => value.toString();

class Counter {}

extension on Counter {
  external int get value;
  external set value(int val);
  external String stringify();


var export = ExportCounter();
var counter = createDartExport(export) as Counter;
export.value = 1;
Expect.isTrue(counter.value, export.value);
Expect.isTrue(counter.stringify(), export.stringify());


external Object createDartExport<T extends Object>(T dartObject);