callMethod method

bool callMethod(
  1. String name,
  2. dynamic arguments
)

Searches the method named name in this and execute it.

It returns true if a method of the given name was found and executed.

The name has the value of Identifier.toString(). It is not a human readable name nor the name of the property that it holds.

This method should not be called manually.

Implementation

bool callMethod(String name, dynamic arguments) {
  Function? implementation = methods[name];
  if (implementation != null) {
    if (arguments == null) {
      implementation();
    } else {
      implementation(arguments);
    }
    return true;
  }

  if (children == null) return false;

  for (AbstractTouchBarItem child in children!) {
    if (child is CallableItem && child.callMethod(name, arguments) == true) {
      return true;
    }
  }

  return false;
}