flutter-asset-integration
Turn a generated asset on disk into a Flutter widget that screens can import and render. Idempotent: safe to re-run when assets change.
Inputs
outputPath— the SVG file (e.g.assets/illustrations/baby-sizes/week-12.svg)<outputPath>.meta.json— sidecar with alt-text and dimensionsrequirements.json(fromasset-requirements-analysis) — lists usage sitesassetId,assetWidgetName,dimensionWidth,dimensionHeight— passed via task vars
Output
lib/widgets/assets/<assetId>_asset.dart— a Material widget wrappingSvgPicture.asset:
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
/// {{alt_text from .meta.json}}
class {{assetWidgetName}}Asset extends StatelessWidget {
const {{assetWidgetName}}Asset({super.key, this.width, this.height, this.semanticsLabel});
final double? width;
final double? height;
final String? semanticsLabel;
@override
Widget build(BuildContext context) {
return SvgPicture.asset(
'{{outputPath}}',
width: width ?? {{dimensionWidth}}.0,
height: height ?? {{dimensionHeight}}.0,
semanticsLabel: semanticsLabel ?? '{{alt_text}}',
);
}
}
pubspec.yaml— ensure the asset directory is listed underflutter.assets. Skip if already present.Usage swap — for each entry in
requirements.usage, replace placeholder widget references (Placeholder(),SizedBox(), or a named widget marker) withconst {{assetWidgetName}}Asset(). Preserve indentation and surrounding code.
Idempotency rules
- Regex-check the target file for the import line before inserting; never duplicate imports.
- Don't touch lines outside the named usage site.
- Run
dart format lib/widgets/assets/<assetId>_asset.dartafter writing. - If the wrapper widget file already exists and is identical, skip — don't overwrite.
What this skill does NOT do
- Doesn't run
flutter pub get(the playbook'spub-getgoal handles that). - Doesn't run
dart analyze(downstreamanalyze-cleangoal handles that). - Doesn't add
flutter_svgtopubspec.yaml's dependencies (already present in baby-app's hand-written pubspec).
Source: openplaybooks-dev/converge-example-baby-app — distributed by TomeVault.