Code Generation Workflows

Automate Flutter boilerplate generation with build_runner, freezed, and related tools.

1|Updated Apr 28, 2024
One-click install
npx skills add https://github.com/HabitaNexus/monorepo --skill code-generation-workflows-habitanexus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Code Generation Workflows
Source: https://github.com/HabitaNexus/monorepo/tree/main/skills/flutter/code-generation
Command: npx skills add https://github.com/HabitaNexus/monorepo --skill code-generation-workflows-habitanexus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Flutter code generation reduces boilerplate and boosts reliability by generating boilerplate for models, serialization, dependency injection, and navigation.

Core Features & Use Cases

  • Setup and configure build_runner, freezed, json_serializable, injectable, and auto_route to automate model creation, JSON serialization, DI, and navigation code.
  • Support for watch mode and conflict resolution to keep generated code in sync with evolving schemas.
  • Real-world use cases include generating immutable models and routes from simple schemas to speed up app initialization and maintain consistency.

Quick Start

Run the build_runner pipeline from the project root to generate code for your app, including models, DI, and routes.

Frequently Asked Questions about Code Generation Workflows

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate Flutter code generation for immutable models and JSON serialization?

Automate Flutter code generation by configuring build_runner with freezed and json_serializable to generate immutable data models and serialization boilerplate from your schemas. This workflow enforces proper build.yaml setup and project-root awareness to keep generated files synced.

What is the best way to manage build_runner conflicts when regenerating Flutter code?

The best way to manage build_runner conflicts during Flutter code generation is to use supported watch mode and conflict resolution workflows. This keeps generated code reliably in sync with evolving schemas during regeneration.

Can I set up dependency injection and navigation code generation together in a Flutter app?

Yes, you can configure injectable for dependency injection and auto_route for navigation alongside freezed and json_serializable. This unified build_runner pipeline automates boilerplate creation for DI configurations and complex navigation routes.

Do I need a build.yaml configuration file to run Flutter code generation workflows?

Yes, a proper build.yaml configuration file is required to run Flutter code generation workflows. It ensures build_runner correctly executes freezed, json_serializable, injectable, and auto_route generators from the project root.

Why does my generated Flutter code fail to sync after schema changes?

Generated Flutter code fails to sync after schema changes when build_runner pipelines are not reliably regenerated or project-root configurations are incorrect. Running the generation workflow from the project root ensures schema changes update the immutable models and routes.