📱 Flutter Intermediate

What is the Hero animation in Flutter?

Why Interviewers Ask This

Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.

Answer

The Hero animation creates a smooth "shared element" transition where a widget appears to fly from one screen to another during navigation. Both the source and destination widgets must be wrapped in a Hero widget with the same tag value. Flutter automatically handles the animation between the two positions and sizes. It is commonly used for image galleries or product cards where the item image expands into a detail view. The tag must be unique among all visible Hero widgets at any given time.

Common Mistake

A common mistake is memorizing definitions without understanding implications. When asked this question, go one level deeper — explain what happens when this concept is misused or ignored.