RouteRegistryEditor class
Route registration injection utilities for RouteServiceProvider.boot().
Provides safe, idempotent mutations of the consumer's
RouteServiceProvider Dart source file: inserting or removing route
registration function calls inside the boot() body, and delegating
import injection to ConfigEditor.
The implementation never evaluates Dart source as code. It operates
entirely on the raw string content using a brace-counting state machine to
locate the boot() body boundaries, then injects the call line at the
correct position.
Usage
RouteRegistryEditor.addRouteRegistration(
'lib/app/providers/route_service_provider.dart',
'registerMyPluginRoutes',
);
RouteRegistryEditor.addRouteImport(
'lib/app/providers/route_service_provider.dart',
"import 'package:my_plugin/routes.dart';",
);
RouteRegistryEditor.removeRouteRegistration(
'lib/app/providers/route_service_provider.dart',
'registerMyPluginRoutes',
);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
addRouteImport(
String providerPath, String importStatement) → void -
Adds an import statement to
providerPath, delegating to ConfigEditor.addImportToFile. -
addRouteRegistration(
String providerPath, String registerFunctionName) → void -
Inserts a call to
registerFunctionName();inside theboot()method of theRouteServiceProvideratproviderPath. -
removeRouteRegistration(
String providerPath, String registerFunctionName) → void -
Removes the call line
[registerFunctionName]();from theboot()body of theRouteServiceProvideratproviderPath.