isTypeTransferable method

bool isTypeTransferable (
  1. DartType type
)

return true if the type is transferable through dart:js (see https://api.dartlang.org/docs/channels/stable/latest/dart_js.html)

Implementation

bool isTypeTransferable(DartType type) {
  const transferables = <String, List<String>>{
    'dart.js': ['JsObject'],
    'dart.core': ['num', 'bool', 'String', 'DateTime'],
    'dart.dom.html': ['Blob', 'Event', 'ImageData', 'Node', 'Window'],
    'dart.dom.indexed_db': ['KeyRange'],
    'dart.typed_data': ['TypedData'],
  };
  for (final libName in transferables.keys) {
    if (getLib(lib, libName) == null) continue;
    if (transferables[libName].any((className) =>
        type.isSubtypeOf(getType(lib, libName, className).type))) {
      return true;
    }
  }
  return false;
}