Fernando Tiberti Fernando Tiberti - 1 year ago 128
Dart Question

How to make a JSON object and pass this JSON object into an external JavaScript function?

I'm developing a game in Dart, and I want to migrate the drawing to PIXI.js. Basically one approach that occurred to me is to convert the game state into a JSON object, and pass this JSON object to an external JS method, which would then create the PIXI containers.

How do I make a JSON object and how do I pass it to an external JavaScript function?

Answer Source
import 'dart:convert';


var json = JSON.encode(data);
var data = JSON.decode(json);

You probably want to use https://pub.dartlang.org/packages/js for dart-js-interop.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download