registerOnClickListener static method

Future<bool> registerOnClickListener(
  1. OnClickListener callBackFunction
)

If a widget is pressed check the type of tap. and returns to the client-dart the component that has been pressed as a string with his tag.

Implementation

static Future<bool> registerOnClickListener(
    OnClickListener callBackFunction) async {
  final callBackDispatcher =
      PluginUtilities.getCallbackHandle(callbackDispatcher)!;
  final callBack = PluginUtilities.getCallbackHandle(callBackFunction)!;
  _platform.setMethodCallHandler((MethodCall call) {
    switch (call.method) {
      case "callBack":
        dynamic arguments = call.arguments;
        if (arguments is List) {
          final type = arguments[0];
          if (type == "onClick") {
            final tag = arguments[1];
            callBackFunction(tag);
          }
        }
    }
    return null;
  } as Future<dynamic> Function(MethodCall)?);
  await _platform.invokeMethod("registerCallBackHandler",
      <dynamic>[callBackDispatcher.toRawHandle(), callBack.toRawHandle()]);
  return true;
}