removeRouteConstant function

String removeRouteConstant(
  1. String content,
  2. String routeName
)

Removes the static const String <routeName> = ...; line from an app_routes.dart body. home is preserved.

Implementation

String removeRouteConstant(String content, String routeName) {
  final pattern = RegExp(
    r'[ \t]*static const String ' +
        RegExp.escape(routeName) +
        r"\s*=\s*'[^']*';\n?",
  );
  return content.replaceAll(pattern, '');
}