makeRouteGuard static method

dynamic makeRouteGuard(
  1. String className,
  2. String value, {
  3. String folderPath = routeGuardsFolder,
  4. bool forceCreate = false,
})

Creates a new Route Guard.

Implementation

static makeRouteGuard(String className, String value,
    {String folderPath = routeGuardsFolder, bool forceCreate = false}) async {
  String name = className.replaceAll(RegExp(r'(_?route_guard)'), "");

  String filePath = '$folderPath/${name.snakeCase}_route_guard.dart';

  await _makeDirectory(folderPath);
  await _checkIfFileExists(filePath, shouldForceCreate: forceCreate);
  await _createNewFile(filePath, value, onSuccess: () {
    MetroConsole.writeInGreen('[Route Guard] ${name.snakeCase} created 🎉');
  });
}