passsy / extract-widgetsr4
Extract Widgets Instead of _buildX() Methods
PublicExtract UI sections into public widget classes instead of Widget _buildX() methods, so tests can find them by type and the tree stays easy to query.
detector.tsisolate · reads files, writes none · no network · 100 ms · 32 MBEdit
import { mentioned, onPrompt, onWrite } from "@wellactually/sdk/v3";
import { DART_WITHOUT_TESTS, isDartProject } from "dart-kit";
onPrompt({
*detect(event) {
if (isDartProject(event)) {
yield* mentioned(event, ["build method", "build methods"]);
}
},
});
onWrite({
globs: DART_WITHOUT_TESTS,
*detect(event) {
for (const written of event.written) {
if (/Widget\s+_build\w*\(/.test(written.text)) {
yield { line: written.line };
}
}
},
});
fixtures/dart_app/pubspec.yamlEdit
namedemo
package.jsonEdit
{
"name": "extract-widgets",
"private": true,
"dependencies": {
"dart-kit": "*"
},
"tags": [
"flutter"
]
}