ServerReflect.fromElement constructor
ServerReflect.fromElement(
- Element? element
Implementation
factory ServerReflect.fromElement(Element? element) {
if (element == null) {
return const ServerReflect.none();
}
if (element is! ClassElement) {
return const ServerReflect.none();
}
if (element.library.isInSdk) {
return const ServerReflect.none();
}
final className = element.displayName;
final metas = <String, List<ServerMimic>>{};
for (final field in element.fields) {
getAnnotations(
element: field,
onMatch: [
OnMatch(
classType: MetaData,
package: 'revali_router_annotations',
convert: (object, annotation) {
final meta = ServerMimic.fromDartObject(object, annotation);
if (field.name3 case final String name) {
(metas[name] ??= []).add(meta);
}
},
),
],
);
}
return ServerReflect(className: className, metas: metas);
}