ClientController.fromMeta constructor

ClientController.fromMeta(
  1. MetaRoute route,
  2. List<ClientLifecycleComponent> parentComponents
)

Implementation

factory ClientController.fromMeta(
  MetaRoute route,
  List<ClientLifecycleComponent> parentComponents,
) {
  final lifecycleComponents = <ClientLifecycleComponent>[...parentComponents];
  var isExcluded = false;

  route.annotationsFor(
    onMatch: [
      OnMatch(
        classType: LifecycleComponent,
        package: 'revali_router_annotations',
        convert: (object, annotation) {
          final component = ClientLifecycleComponent.fromDartObject(
            annotation,
          );

          lifecycleComponents.add(component);
        },
      ),
      OnMatch(
        classType: ExcludeFromClient,
        package: 'revali_client',
        convert: (object, annotation) {
          isExcluded = true;
        },
      ),
    ],
  );

  return ClientController(
    name: route.className,
    isExcluded: isExcluded,
    methods: route.methods
        .map((e) => ClientMethod.fromMeta(e, route.path, lifecycleComponents))
        .toList(),
  );
}