formatScreenName static method

String formatScreenName(
  1. String routeName
)

Implementation

static String formatScreenName(String routeName) {
  // Convert route names to consistent format
  // "/product/electronics" -> "product_electronics"
  // "ProductDetailScreen" -> "product_detail_screen"

  if (routeName.startsWith('/')) {
    return routeName.substring(1).replaceAll('/', '_').toLowerCase();
  }

  // Convert CamelCase to snake_case
  return routeName
      .replaceAllMapped(RegExp(r'([A-Z])'), (match) => '_${match.group(1)!.toLowerCase()}')
      .replaceFirst(RegExp(r'^_'), '')
      .toLowerCase();
}