zoomToSection method

Future<void> zoomToSection(
  1. String section
)

Implementation

Future<void> zoomToSection(String section) async {
  final String promiseId = DateTime.now().millisecondsSinceEpoch.toString();
  final Completer<void> completer = Completer<void>();

  _pendingPromises[promiseId] = completer;

  final String jsonSection = jsonEncode(section);

  await _controller.evaluateJavascript("""
    chart.zoomToSection($jsonSection)
      .then(() => window.zoomToSectionJsChannel.postMessage(JSON.stringify({ "id": "$promiseId", "status": "resolved" })))
      .catch(error => window.zoomToSectionJsChannel.postMessage(JSON.stringify({ "id": "$promiseId", "status": "error", "message": error })));
  """);

  return completer.future;
}