getMethodNames static method

List<String> getMethodNames(
  1. dynamic obj
)

Gets names of all methods implemented in specified object.

  • obj an objec to introspect. Returns a list with method names.

Implementation

static List<String> getMethodNames(obj) {
  var methods = <String>[];

  var cm = reflectClass(obj.runtimeType);
  for (var dm in cm.instanceMembers.values) {
    Symbol? foundName;

    if (dm is MethodMirror &&
        !dm.isGetter &&
        !dm.isSetter &&
        !dm.isStatic &&
        !dm.isPrivate) foundName = dm.simpleName;

    if (foundName != null) methods.add(_extractName(foundName));
  }

  return methods;
}