injectBeforeMagicInit static method
Insert snippet immediately before the line containing Magic.init
in source.
Delegates to MainDartEditor.injectBeforeAnchor with anchor: 'Magic.init',
pinning the anchor so callers never hardcode it.
Idempotent: returns source unchanged when snippet (trimmed) is already
present, or when no line in source contains 'Magic.init'.
When indent is supplied it is prepended to every non-blank line of
snippet before insertion.
@param source The full source text to transform.
@param snippet The text block to insert, including trailing newline(s).
@param indent Optional leading whitespace to prepend to each snippet line.
@return The transformed source, or source unchanged.
Implementation
static String injectBeforeMagicInit({
required String source,
required String snippet,
String? indent,
}) {
return MainDartEditor.injectBeforeAnchor(
source: source,
anchor: 'Magic.init',
snippet: snippet,
indent: indent,
);
}