resolve method
Resolves application routes using the provided context.
Returns the routes derived from the generated feature and template routing configuration.
Implementation
Future<List<ResolvedRoute>> resolve(GeneratorContext context) async {
final router = context.template.router;
if (!router.enabled) return const [];
final featuresDirectory = Directory(context.config.featureDir);
if (!featuresDirectory.existsSync()) return const [];
final routes = <ResolvedRoute>[];
await for (final entity in featuresDirectory.list(recursive: true, followLinks: false)) {
if (entity is! File) continue;
final fileName = _fileName(entity.path);
if (!fileName.endsWith(router.screenSuffix)) continue;
if (_isIgnored(fileName, router.ignore)) continue;
if (!_isInsideScreenFolder(entity.path, router.screenFolder)) continue;
final routeName = _resolveRouteName(fileName, router.screenSuffix);
routes.add(
ResolvedRoute(
name: _snakeToCamel(routeName),
path: '/${routeName.replaceAll('_', '-')}',
className: _snakeToPascal(fileName.replaceFirst('.dart', '')),
file: entity.path),
);
}
routes.sort((a, b) => a.path.compareTo(b.path));
return routes;
}