makeRouteGuard static method
Creates a new Route Guard.
Implementation
static Future<void> makeRouteGuard(
String className,
String value, {
String folderPath = routeGuardsFolder,
bool forceCreate = false,
String? creationPath,
}) async {
String name = className.replaceAll(RegExp(r'(_?route_guard)'), "");
await _makeDirectory(folderPath);
await createDirectoriesFromCreationPath(creationPath, folderPath);
String filePath = createPathForDartFile(
folderPath: folderPath,
className: name,
prefix: "route_guard",
creationPath: creationPath,
);
await _checkIfFileExists(filePath, shouldForceCreate: forceCreate);
await _createNewFile(
filePath,
value,
onSuccess: () {
final linkText = name.snakeCase;
final link = MetroConsole.hyperlink(linkText, filePath);
MetroConsole.writeInGreen('[Route Guard] $link created 🎉');
},
);
}