text stringlengths 1 372 |
|---|
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 animations |
learn 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 widget |
learn about the AnimatedPadding flutter widget |
learn about the AnimatedPositioned flutter widget |
learn 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, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.