FLUTTER ANIMATION - 1 | Animating Widgets | AnimatedContainer

Veröffentlicht am: 11 Mai 2023
auf dem Kanal: True Coders
599
11

https://www.youtube.com/@truecoders?s...
‪@TrueCoders‬

AnimatedContainer: The AnimatedContainer widget animates changes to its properties, such as its size, color, and padding.

The AnimatedContainer is a built-in Flutter widget that animates changes to its properties, such as size, color, padding, border, and decoration. The widget is similar to the Container widget, but it adds animation capabilities to its properties.

When a property of the AnimatedContainer changes, the widget automatically animates the transition between the old and new values. For example, if the size of the AnimatedContainer changes from small to large, the widget smoothly animates the size change rather than abruptly changing the size.

The AnimatedContainer widget takes a duration parameter that specifies the duration of the animation. Developers can also specify the animation curve to use for the transition. The widget automatically animates changes to its properties using the provided duration and curve.


Here's an example of using the AnimatedContainer widget:

AnimatedContainer(
duration: Duration(seconds: 1),
curve: Curves.fastOutSlowIn,
height: _isExpanded ? 200.0 : 100.0,
width: _isExpanded ? 200.0 : 100.0,
color: _isExpanded ? Colors.red : Colors.blue,
child: Center(
child: Text('Click me'),
),
)

In this example, the AnimatedContainer changes its height, width, and color properties based on the value of `_isExpanded`. When `_isExpanded` is true, the AnimatedContainer expands to a height and width of 200.0 and changes color to red. When `_isExpanded` is false, the AnimatedContainer contracts to a height and width of 100.0 and changes color to blue. The animation uses a duration of 1 second and the `fastOutSlowIn` curve for a smooth and natural transition.


Auf dieser Seite können Sie das Online-Video FLUTTER ANIMATION - 1 | Animating Widgets | AnimatedContainer mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer True Coders 11 Mai 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 599 Mal angesehen und es wurde von 11 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!