Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Flutter
  2. widgets.dart
  3. AnimatedWidget class
AnimatedWidget
description

AnimatedWidget classabstract

A widget that rebuilds when the givenListenable changes value.

AnimatedWidget is most commonly used withAnimation objects, which areListenable, but it can be used with anyListenable, includingChangeNotifier andValueNotifier.

AnimatedWidget is most useful for widgets that are otherwise stateless. TouseAnimatedWidget, subclass it and implement the build function.

This code defines a widget calledSpinner that spins a green squarecontinually. It is built with anAnimatedWidget.
link

To create a local project with this code sample, run:
flutter create --sample=widgets.AnimatedWidget.1 mysample

For more complex case involving additional state, consider usingAnimatedBuilder orListenableBuilder.

Relationship toImplicitlyAnimatedWidgets

AnimatedWidgets (and their subclasses) take an explicitListenable asargument, which is usually anAnimation derived from anAnimationController. In most cases, the lifecycle of thatAnimationController has to be managed manually by the developer.In contrast to that,ImplicitlyAnimatedWidgets (and their subclasses)automatically manage their own internalAnimationController making thoseclasses easier to use as no externalAnimation has to be provided by thedeveloper. If you only need to set a target value for the animation andconfigure its duration/curve, consider using (a subclass of)ImplicitlyAnimatedWidgets instead of (a subclass of) this class.

Common animated widgets

A number of animated widgets ship with the framework. They are usually namedFooTransition, whereFoo is the name of the non-animatedversion of that widget. The subclasses of this class should not be confusedwith subclasses ofImplicitlyAnimatedWidget (see above), which are usuallynamedAnimatedFoo. Commonly used animated widgets include:

Inheritance
Implementers

Constructors

AnimatedWidget({Key?key,requiredListenablelistenable})
Creates a widget that rebuilds when the given listenable changes.
const

Properties

hashCodeint
The hash code for this object.
no setterinherited
keyKey?
Controls how one widget replaces another widget in the tree.
finalinherited
listenableListenable
TheListenable to which this widget is listening.
final
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContextcontext)Widget
Override this method to build widgets that depend on the state of thelistenable (e.g., the current value of the animation).
createElement()StatefulElement
Creates aStatefulElement to manage this widget's location in the tree.
inherited
createState()State<AnimatedWidget>
Subclasses typically do not override this method.
override
debugDescribeChildren()List<DiagnosticsNode>
Returns a list ofDiagnosticsNode objects describing this node'schildren.
inherited
debugFillProperties(DiagnosticPropertiesBuilderproperties)→ void
Add additional properties associated with the node.
override
noSuchMethod(Invocationinvocation)→ 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 debuggingtools and byDiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevelminLevel =DiagnosticLevel.info})String
A string representation of this object.
inherited
toStringDeep({StringprefixLineOne ='',String?prefixOtherLines,DiagnosticLevelminLevel =DiagnosticLevel.debug,intwrapWidth =65})String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({Stringjoiner =', ',DiagnosticLevelminLevel =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 ==(Objectother)bool
The equality operator.
inherited
  1. Flutter
  2. widgets
  3. AnimatedWidget class
widgets library

[8]ページ先頭

©2009-2025 Movatter.jp