smf_contribution_engine library

Patches existing Dart files: adds imports and statements, inserts list elements, replaces widgets and edits their arguments.

Each change is a Contribution that finds its target in the parsed file. PatchEngine applies contributions to a project and renders the Mustache placeholders in the text they insert.

Classes

Contribution
A change to one Dart file, such as an import to add or a widget to replace.
InsertImport
Adds an import directive to file, unless the file already has it.
InsertIntoFunction
Inserts statements into the body of a top-level function, next to the statements that contain an anchor text.
InsertIntoListInFunction
Adds an element at the start of a list literal passed as a named argument, such as the providers of a MultiProvider built in main.
InsertIntoListInMethodInClass
Adds an element at the end of a list literal passed as a named argument in a method, such as the supportedLocales of the MaterialApp built in MainApp.build.
InsertIntoMethodInClass
Inserts statements into the body of a method, after the statements that contain an anchor text, such as a call in initState after super.initState();.
ModifyWidgetArguments
Removes, overrides and appends named arguments of a widget, such as swapping home for routerConfig on MaterialApp.router.
PatchEngine
Applies contributions to the files under projectRoot.
ReplaceWidget
Replaces the type name of a widget, such as MaterialApp with MaterialApp.router, keeping its arguments.