text
stringlengths
1
372
the destination route. the overlay is now empty.
the destination hero appears in its final position
in the destination route.
the source hero is restored to its route.
popping the route performs the same process,
animating the hero back to its size
and location in the source route.
<topic_end>
<topic_start>
essential classes
the examples in this guide use the following classes to
implement hero animations:
<topic_end>
<topic_start>
standard hero animations
<topic_end>
<topic_start>
what's the point?
standard hero animation code
each of the following examples demonstrates flying an image from one
route to another. this guide describes the first example.
<topic_end>
<topic_start>
what’s going on?
flying an image from one route to another is easy to implement
using flutter’s hero widget. when using MaterialPageRoute
to specify the new route, the image flies along a curved path,
as described by the material design motion spec.
create a new flutter example and
update it using the files from the hero_animation.
to run the example:
<topic_end>
<topic_start>
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:
<topic_end>
<topic_start>
HeroAnimation class
the HeroAnimation class creates the source and destination
PhotoHeroes, and sets up the transition.
here’s the code:
key information:
<topic_end>
<topic_start>
radial hero animations
<topic_end>
<topic_start>
what's the point?
flying a hero from one route to another as it transforms
from a circular shape to a rectangular shape is a slick
effect that you can implement using hero widgets.
to accomplish this, the code animates the intersection of
two clip shapes: a circle and a square.
throughout the animation, the circle clip (and the image)
scales from minRadius to maxRadius, while the square
clip maintains constant size. at the same time,
the image flies from its position in the source route to its
position in the destination route. for visual examples
of this transition, see radial transformation
in the material motion spec.
this animation might seem complex (and it is), but you can customize the
provided example to your needs. the heavy lifting is done for you.
radial hero animation code
each of the following examples demonstrates a radial hero animation.
this guide describes the first example.
pro tip:
the radial hero animation involves intersecting a round shape with
a square shape. this can be hard to see, even when slowing
the animation with timeDilation, so you might consider enabling
the debugPaintSizeEnabled flag during development.
<topic_end>
<topic_start>
what’s going on?
the following diagram shows the clipped image at the beginning
(t = 0.0), and the end (t = 1.0) of the animation.
the blue gradient (representing the image), indicates where the clip
shapes intersect. at the beginning of the transition,
the result of the intersection is a circular clip (clipoval).
during the transformation, the ClipOval scales from minRadius
to maxRadius while the ClipRect maintains a constant size.
at the end of the transition the intersection of the circular and
rectangular clips yield a rectangle that’s the same size as the hero
widget. in other words, at the end of the transition the image is no
longer clipped.
create a new flutter example and
update it using the files from the
radial_hero_animation GitHub directory.
to run the example:
<topic_end>
<topic_start>
photo class
the photo class builds the widget tree that holds the image:
key information:
<topic_end>
<topic_start>
RadialExpansion class