text
stringlengths
1
474
super.dispose();
}
}<code_end>
App source: animate5<topic_end>
<topic_start>
Next steps
This tutorial gives you a foundation for creating animations in
Flutter using Tweens, but there are many other classes to explore.
You might investigate the specialized Tween classes,
animations specific to Material Design,
ReverseAnimation,
shared element transitions (also known as Hero animations),
physics simulations and fling() methods.
See the animations landing page
for the latest available documents and examples.
<topic_end>
<topic_start>Implicit animations
With Flutter’s animation library,
you can add motion and create visual effects
for the widgets in your UI.
One part of the library is an assortment of widgets
that manage animations for you.
These widgets are collectively referred to as implicit animations,
or implicitly animated widgets, deriving their name from the
ImplicitlyAnimatedWidget class that they implement.
The following set of resources provide many ways to learn
about implicit animations in Flutter.<topic_end>
<topic_start>
Documentation
<topic_end>
<topic_start>
Flutter in Focus videos
Flutter in Focus videos feature 5-10 minute tutorials
with real code that cover techniques
that every Flutter dev needs to know from top to bottom.
The following videos cover topics
that are relevant to implicit animations.Learn about Animation Basics with Implicit AnimationsLearn about building Custom Implicit Animations with TweenAnimationBuilder<topic_end>
<topic_start>
The Boring Show
Watch the Boring Show to follow Google Engineers build apps
from scratch in Flutter. The following episode covers
using implicit animations in a news aggregator app.Learn about implicitly animating the Hacker News app<topic_end>
<topic_start>
Widget of the Week videos
A weekly series of short animated videos each showing
the important features of one particular widget.
In about 60 seconds, you’ll see real code for each
widget with a demo about how it works.
The following Widget of the Week videos cover
implicitly animated widgets:Learn about the AnimatedOpacity Flutter WidgetLearn about the AnimatedPadding Flutter WidgetLearn about the AnimatedPositioned Flutter WidgetLearn about the AnimatedSwitcher Flutter Widget
<topic_end>
<topic_start>Animate the properties of a container
The Container class provides a convenient way
to create a widget with specific properties:
width, height, background color, padding, borders, and more.Simple animations often involve changing these properties over time.
For example,
you might want to animate the background color from grey to green to
indicate that an item has been selected by the user.To animate these properties,
Flutter provides the AnimatedContainer widget.
Like the Container widget, AnimatedContainer allows you to define
the width, height, background colors, and more. However, when the
AnimatedContainer is rebuilt with new properties, it automatically
animates between the old and new values. In Flutter, these types of
animations are known as “implicit animations.”This recipe describes how to use an AnimatedContainer to animate the size,
background color, and border radius when the user taps a button
using the following steps:<topic_end>
<topic_start>
1. Create a StatefulWidget with default properties
To start, create StatefulWidget and State classes.
Use the custom State class to define the properties that change over
time. In this example, that includes the width, height, color, and border
radius. You can also define the default value of each property.These properties belong to a custom State class so they
can be updated when the user taps a button.
<code_start>class AnimatedContainerApp extends StatefulWidget {
const AnimatedContainerApp({super.key});
@override
State<AnimatedContainerApp> createState() => _AnimatedContainerAppState();
}
class _AnimatedContainerAppState extends State<AnimatedContainerApp> {
// Define the various properties with default values. Update these properties
// when the user taps a FloatingActionButton.
double _width = 50;
double _height = 50;
Color _color = Colors.green;
BorderRadiusGeometry _borderRadius = BorderRadius.circular(8);
@override
Widget build(BuildContext context) {
// Fill this out in the next steps.
}
}<code_end>
<topic_end>
<topic_start>
2. Build an AnimatedContainer using the properties
Next, build the AnimatedContainer using the properties defined in the
previous step. Furthermore, provide a duration that defines how long
the animation should run.
<code_start>AnimatedContainer(
// Use the properties stored in the State class.
width: _width,
height: _height,