addJavascriptCode method

  1. @override
Future<void> addJavascriptCode(
  1. String code
)
override

Implementation

@override
Future<void> addJavascriptCode(String code) async {
  await _ensureBridgeInitialized();

  try {
    final scriptElement = web.HTMLScriptElement()
      ..type = 'text/javascript'
      ..text = code;

    web.document.head?.appendChild(scriptElement);
  } catch (e) {
    throw Exception('Failed to add JavaScript code: $e');
  }
}