parseRoute method
Future<MetaRoute?>
parseRoute(
- File file
)
Implementation
Future<MetaRoute?> parseRoute(File file) async {
if (!path.basename(file.path).contains(RegExp(r'[._]controller\.dart$'))) {
return null;
}
final resolved = await _resolve(file.path, fs);
final classVisitor = ControllerVisitor();
resolved.libraryElement.accept(classVisitor);
if (!classVisitor.hasController) {
return null;
}
final (:element, path: routePath, :constructor, :params, :methods) =
classVisitor.values;
return MetaRoute(
path: routePath,
filePath: file.path,
className: element.name,
params: params,
element: element,
constructorName: constructor.name,
methods: methods,
annotationsFor: ({
required List<OnMatch> onMatch,
NonMatch? onNonMatch,
}) =>
getAnnotations(
element: element,
onMatch: onMatch,
onNonMatch: onNonMatch,
),
);
}