PhotoHero class

The custom PhotoHero class maintains the hero,
and its size, image, and behavior when tapped.
The PhotoHero builds the following widget tree:

Here’s the code:

Key information:

The starting route is implicitly pushed by MaterialApp when
HeroAnimation is provided as the app’s home property.

An InkWell wraps the image, making it trivial to add a tap
gesture to the both the source and destination heroes.

Defining the Material widget with a transparent color
enables the image to “pop out” of the background as it
flies to its destination.

The SizedBox specifies the hero’s size at the start and
end of the animation.

Setting the Image’s fit property to BoxFit.contain,
ensures that the image is as large as possible during the
transition without changing its aspect ratio.

HeroAnimation class