getName abstract method

String getName()

Gets the declared name of the source.

Returns:

  • The source name as declared in source
  • Empty string for positional parameters
  • The method name as declared in source
  • Includes getter/setter prefixes when applicable
  • The constructor name as declared in source
  • Empty string for default unnamed constructors
  • The simple type name (e.g., String, List<int>)
  • May include generic parameters when available

Example: - Class

Class.forType<Map<String, int>>().getName(); // 'Map<String, int>'

Examples: - Constructor

  • '' for ClassName()
  • 'fromJson' for ClassName.fromJson()

Examples: - Method

  • 'toString'
  • 'operator=='
  • 'get length' (for getters)
  • 'set items' (for setters)

Examples: - Parameter

void method(String param1, {int param2}) {}
// getName() returns:
// '' for param1 (positional)
// 'param2' for named param

Implementation

String getName();