handlerCallback static method
Returns a callback ready to plug into
controller.addJavaScriptHandler(handlerName: BRIDGE_NAME, callback: …).
Each incoming message is routed through the FlareLane bridge core; if
the core returns a JS string (e.g. the syncDeviceData response), it
is evaluated back into the webview via the controller.
Implementation
static Future<void> Function(List<dynamic>) handlerCallback(
InAppWebViewController controller) {
return (List<dynamic> args) async {
final String message =
args.isNotEmpty && args.first is String ? args.first as String : '';
if (message.isEmpty) return;
final String? js = await BridgeCore.handle(message);
if (js != null) {
await controller.evaluateJavascript(source: js);
}
};
}