hasMethod static method

bool hasMethod(
  1. dynamic obj,
  2. String name
)

Checks if object has a method with specified name..

  • obj an object to introspect.
  • name a name of the method to check. Returns true if the object has the method and false if it doesn't.

Implementation

static bool hasMethod(obj, String name) {
  if (obj == null) throw Exception('Object cannot be null');
  // if (name == null) throw Exception('Method name cannot be null');

  var foundName = _findMethod(obj, name);
  return foundName != null;
}