MainDartSmartMerger class
Preserve-mode smart merger for lib/main.dart.
Takes an existing user-authored main.dart source string and surgically
injects Magic without overwriting the user's code: adds Magic + Wind
imports, injects await Magic.init(...) at the top of main(), and
wraps the existing runApp(X) call with MagicApplication(child: X, appName: '<name>').
All three mutations are idempotent: re-running on already-merged source returns equivalent output (no duplicate imports, no double Magic.init, no double wrap).
Constraints
- Only
void main() async { ... }orFuture<void> main() async { ... }shapes are supported. A synchronousmain()is rejected with a FormatException whose message names both--preserve(re-run after converting to async) and--force(replace entirely) as alternatives. - The existing source MUST contain a
runApp(...)call. When absent a StateError is thrown.
Usage
final merged = MainDartSmartMerger.mergeMagicInto(
existingSource,
appName: 'Uptizm',
configImports: ["import 'config/app.dart';"],
configFactories: ['() => appConfig'],
);
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