findObject method

Future<SeatsioObject> findObject(
  1. String objectLabel
)

Implementation

Future<SeatsioObject> findObject(String objectLabel) async {
  final String promiseId = DateTime.now().millisecondsSinceEpoch.toString();
  final Completer<SeatsioObject> completer = Completer();

  _pendingPromises[promiseId] = completer;

  final String objectLabelString = jsonEncode(objectLabel);

  await _controller.evaluateJavascript("""
  chart.findObject($objectLabelString)
    .then(object => {
      window.findObjectJsChannel.postMessage(JSON.stringify({
        \"id\": \"$promiseId\",
        \"status\": \"resolved\",
        \"object\": object
      }));
    })
    .catch(error => {
      window.findObjectJsChannel.postMessage(JSON.stringify({
        \"id\": \"$promiseId\",
        \"status\": \"error\",
        \"message\": error
      }));
    });
""");

  return completer.future;
}