execute method

void execute(
  1. String statement
)

For internal use only. Implementation detail that may change anytime.

Evaluates the JavaScript statement given.

Implementation

void execute(String statement) {
  final controller = _webViewController;

  if (controller != null) {
    if (kDebugMode) {
      print('📗 chatbox.execute: $statement');
    }

    // This statemement without the `true;` at the end results in a build that crashes on iOS 26.2 when built using Xcode 26.2
    // Building on Xcode 26.1.1 and running on iOS 26.2 does not result in a crash.
    controller.evaluateJavascript(source: '$statement; true;');
  } else {
    if (kDebugMode) {
      print('📘 chatbox.execute: $statement');
    }

    this._pending.add(statement);
  }
}