📢 Beta Documentation – This documentation and plugin are under active development. The plugin is live and ready to explore, but docs are in beta. Final release coming in May 2026. Please explore, test, and share feedback!

Build Runner

Learn how to generate code successfully via Flutter's build_runner package.

Riverpod Generator relies completely on the Dart build_runnerecosystem. Without it, your syntax remains unresolved, and the generated files (*.g.dart) are simply missing.

Running the Generator Once

Run code generation one time after making substantial file changes:

dart run build_runner build -d

Note: -d or --delete-conflicting-outputs is highly recommended to resolve file conflicts gracefully.

Running the Generator Continuously (Watch)

Instead of constantly rebuilding, run the watcher. It regenerates files on the fly as you code, saving massive amounts of time.

dart run build_runner watch -d

Troubleshooting Build Failures

  • Outdated dependencies: Run flutter clean and flutter pub get to refresh your Dart cache.
  • Missing part declarations: The generator expects part 'filename.g.dart'; at the top of your Dart file.
  • Syntax errors: If the source file has syntax errors, the build step might fail silently. Check your Dart Analyzer output.
  • Stale files: ALWAYS append the -d flag to prevent conflicting generated output issues.