ClientLifecycleComponent.fromDartObject constructor

ClientLifecycleComponent.fromDartObject(
  1. DartObject object,
  2. ElementAnnotation annotation
)

Implementation

factory ClientLifecycleComponent.fromDartObject(
  DartObject object,
  // ignore: avoid_unused_constructor_parameters
  ElementAnnotation annotation,
) {
  if (object.type case final InterfaceType type) {
    final element = type.element;
    if (element is! ClassElement) {
      throw Exception('Invalid element type');
    }

    return ClientLifecycleComponent.fromClassElement(
      element,
      typeArguments: type.typeArguments,
    );
  }

  throw Exception('Expected annotation type to be InterfaceType');
}