MethodAnnotation.fromAnnotation constructor
MethodAnnotation.fromAnnotation(
- DartObject annotation
Implementation
factory MethodAnnotation.fromAnnotation(DartObject annotation) {
final className = annotation.type?.getDisplayString();
if (className == '$SSE') {
return SseMethodAnnotation.fromAnnotation(annotation);
}
final name = getFieldValueFromDartObject(annotation, 'name');
if (name == null) {
throw Exception('Method name is required');
}
final path = getFieldValueFromDartObject(annotation, 'path');
final isWebSocket = className == '$WebSocket';
if (isWebSocket) {
return WebSocketAnnotation.fromAnnotation(
annotation,
name: name,
path: path,
);
}
return MethodAnnotation(
name,
path: path,
);
}