createPageWithRoute method

void createPageWithRoute(
  1. String pageName,
  2. String path,
  3. List arguments
)

Implementation

void createPageWithRoute(
    String pageName, String path, List<dynamic> arguments) {
  final appFolder = 'lib/app';
  final routesPath = '$appFolder/routes';
  if (arguments[1].toString().startsWith('page:')) {
    // Ensure the app/routes folder and files exist
    _ensureRoutesSetup(routesPath);

    // Check if the route already exists
    if (_routeExists(pageName, routesPath)) {
      print(
          'Error: Route for "$pageName" already exists in the routing files.');
      return;
    }
  }

  // Proceed to create the page
  createPage(pageName, path, routesPath, arguments);
}