js_interop_utils 1.0.3 copy "js_interop_utils: ^1.0.3" to clipboard
js_interop_utils: ^1.0.3 copied to clipboard

Platformweb

A Dart library for seamless interaction with JavaScript using `dart:js_interop`, supporting deep transformations of objects, maps, and arrays.

example/js_interop_utils_example.dart

import 'package:js_interop_utils/js_interop_utils.dart';

void main() {
  var jsArrayOfStrings = ['a', 'b'].toJS; // JSArray<JSString>
  print('JSArray<JSString>: $jsArrayOfStrings');

  var jsArrayOfNumbers = [1, 2].toJS; // JSArray<JSNumber>
  print('JSArray<JSNumber>: $jsArrayOfNumbers');

  var jsArrayOfPairs = [
    ['a', 1],
    ['b', 2]
  ].toJSDeep; // JSArray<JSArray<JSAny?>>
  print('JSArray<JSArray<JSAny?>>: $jsArrayOfPairs');

  var jsObject = {
    'a': 1,
    'b': 2,
  }.toJSDeep;
  print('JSObject: $jsObject');

  var jsObject2 = {
    'a': [1, 10],
    'b': [2, 20],
  }.toJSDeep;

  print('JSObject (deep): $jsObject2');
}
1
likes
150
points
224
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart library for seamless interaction with JavaScript using `dart:js_interop`, supporting deep transformations of objects, maps, and arrays.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

More

Packages that depend on js_interop_utils