findExpose method

Expose? findExpose(
  1. Reflector reflector, {
  2. bool concreteOnly = false,
})

Finds the Expose declaration for this class.

If concreteOnly is false, then if there is no actual Expose, one will be automatically created.

Implementation

Expose? findExpose(Reflector reflector, {bool concreteOnly = false}) {
  var existing = reflector
      .reflectClass(runtimeType)!
      .annotations
      .map((m) => m.reflectee)
      .firstWhere((r) => r is Expose, orElse: () => null) as Expose?;
  return existing ??
      (concreteOnly
          ? null
          : Expose(ReCase(runtimeType.toString())
              .snakeCase
              .replaceAll('_controller', '')
              .replaceAll('_ctrl', '')
              .replaceAll(_rgxMultipleUnderscores, '_')));
}