init static method
Implementation
static void init(String apiKey, String userId, {String endpoint = ''}) {
BasicMessageChannel<dynamic> channel =
const BasicMessageChannel("plotline", JSONMessageCodec());
channel.setMessageHandler((message) async {
Map<String, dynamic> messageMap = message;
switch (messageMap["method"]) {
case "getAllElements":
getAllElements(messageMap["listenerId"], messageMap["pixelRatio"],
messageMap["screenWidth"], messageMap["screenHeight"]);
break;
case "areViewsPresent":
areViewsPresent(
messageMap["listenerId"],
messageMap["searchElements"],
messageMap["pixelRatio"],
messageMap["screenWidth"],
messageMap["screenHeight"]);
break;
case "getViewPosition":
getViewPosition(
messageMap["listenerId"],
messageMap["clientElementId"],
messageMap["pixelRatio"],
messageMap["screenWidth"],
messageMap["screenHeight"]);
break;
}
});
if (endpoint.isNotEmpty) {
_channel.invokeMethod('init', <String, dynamic>{
'apiKey': apiKey,
'userId': userId,
'endpoint': endpoint
});
} else {
_channel.invokeMethod('init', <String, dynamic>{
'apiKey': apiKey,
'userId': userId,
});
}
}