getCommands function
Gets all commands generated by one Widget, preferably just used with wrapper Widgets Caution with all Widgets providing not only command functionality, like File, Pack, Execute, If and more
Implementation
List<String> getCommands(Widget w, {Context? context}) {
context ??= Context();
final file = BuildFile.fromWidget(w);
file.generate(
context: context,
pack: BuildPack(
Pack(name: context.packId),
logging: false,
),
);
return file.commands
.toString()
.split('\n')
.takeWhile((l) => l != '')
.toList();
}