getConstructor abstract method

Constructor? getConstructor(
  1. String name
)

Gets a constructor by its declared name.

Parameters:

  • name: The constructor name (empty string for default constructor)

Returns:

  • The matching constructor if found
  • null if no matching constructor exists

Example:

class Point {
  Point.origin() : x = 0, y = 0;
}

final constructor = Class.forType<Point>().getConstructor('origin');

For factory constructors, include the 'factory' prefix:

getConstructor('factory fromJson');

Implementation

Constructor? getConstructor(String name);