Animated class Animation
A widget that applies an animation to state changes in its descendants.
See withAnimation for a function that applies an animation to all state changes that are the result of calling a callback.
Only widgets that support animating with Fleet will animate changes. To implement support for this in your own widgets use AnimatableStatelessWidget or AnimatableSingleChildRenderObjectWidgetMixin.
The following provided widgets support animating with Fleet:
- FleetAlign
- FleetAspectRatio
- FleetCenter
- FleetColoredBox
- FleetColumn
- FleetConstrainedBox
- FleetContainer
- FleetDecoratedBox
- FleetFittedBox
- FleetFlex
- FractionalTranslation
- FleetFractionallySizedBox
- FleetLimitedBox
- FleetOpacity
- FleetOverflowBox
- FleetPadding
- FleetPositioned
- FleetPositionedDirectional
- FleetRow
- FleetSizedBox
- FleetSizedOverflowBox
- FleetSliverOpacity
- FleetSliverPadding
- FleetTransform
The following provided widgets are specific to Fleet:
State changes are only animated if they happen at the same time that value changes. If no value or the alwaysAnimateValue is provided, the animation is applied to all state changes.
Animated can be nested, with the closest enclosing Animated widget taking precedence.
Examples
import 'package:flutter/material.dart';
class MyWidget extends StatefulWidget {
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
var _active = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
setState(() {
_active = !_active;
});
},
child: Animated(
animation: Curves.ease.animation(250.ms),
value: _active,
child: FleetColoredBox(color: _active ? Colors.blue : Colors.grey),
),
);
}
}
See also:
- withAnimation for a function that applies an animation to the state changes caused by calling a callback.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- Animated
- Available Extensions
Constructors
Properties
- animation → AnimationSpec
-
The AnimationSpec to use for animating state changes in descendants.
final
- child → Widget
-
The widget below this widget in the tree.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → Object?
-
When this value changes, coinciding state changes in descendants are
animated.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< Animated> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- alwaysAnimateValue → const Object
- A value that can be provided to animate all state changes in descendants.