callbackDispatcher function

void callbackDispatcher()

Notify to the sender/caller that a widget has been pressed.

Implementation

void callbackDispatcher() {
  const MethodChannel _backgroundChannel =
      const MethodChannel('ni.devotion.floaty_head/background');
  WidgetsFlutterBinding.ensureInitialized();
  _backgroundChannel.setMethodCallHandler((MethodCall call) async {
    final args = call.arguments;
    final Function callback = PluginUtilities.getCallbackFromHandle(
        CallbackHandle.fromRawHandle(args[0]))!;
    final type = args[1];
    if (type == "onClick") {
      final tag = args[2];
      callback(tag);
    }
  });
}