generateClass method
Generates a model class file for the given routeInfo.
Determines the class name and output file path based on the route, then produces the class contents and writes them to disk. The generated class represents the 200-response body for the route (if present).
Implementation
void generateClass(RouteInfo routeInfo) {
String endPoint = 'Model';
String routeName = getRouteName(routeInfo.fullRoute);
String className = '$routeName$endPoint';
String moduleName = getCategory(routeInfo.fullRoute);
List<String> contents = [];
String classContent = _generateClassContent(
className: className,
content: routeInfo.httpMethodInfo.responses.response200?.content,
);
contents.add(classContent);
String filePath = FilePath(
mainPath: mainPath,
category: moduleName,
routeName: routeName,
isMVVM: isMVVM,
).modelFilePath;
final file = File(filePath);
file.parent.createSync(recursive: true);
for (var content in contents) {
file.writeAsStringSync(content);
}
}