What is build_runner in Flutter?
Why Interviewers Ask This
Interviewers ask this to evaluate whether you have the depth of knowledge needed to mentor others and lead technical decisions. The expected answer goes beyond definitions into practical implications and real-world consequences.
Answer
build_runner is a Dart build system that generates source files based on annotations in your code. Run it with flutter pub run build_runner build for a one-time generation or watch for continuous generation during development. It powers several major packages: json_serializable (JSON models), freezed (immutable classes), injectable (dependency injection), hive_generator (Hive adapters), and riverpod_generator. Generated files end in .g.dart or .freezed.dart and should be committed to version control.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Flutter answers easy to follow.