Skip to content

Commit

Permalink
feat!: require animation and value for Animated (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaugold committed Sep 7, 2022
1 parent 23606ef commit 9320506
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions packages/fleet/lib/src/animate.dart
Expand Up @@ -101,8 +101,8 @@ void _debugWarnGlobalTransactionBindingIsNotInitialized() {
_debugDidWarnGlobalTransactionsBindingIsNotInitialized = true;
debugPrint(
'GlobalTransactionBinding has not been initialized. Without it, '
'withAnimationAsync, setStateWithAnimationAsync and Animate cannot apply the '
'provided animation. Make sure you have called '
'withAnimationAsync, setStateWithAnimationAsync and Animate cannot '
'apply the provided animation. Make sure you have called '
'FleetBinding.ensureInitialized() before runApp.',
);
}
Expand Down Expand Up @@ -199,15 +199,11 @@ extension SetStateWithAnimationExtension on State {
/// {@endtemplate}
///
/// State changes are only animated if they happen at the same time that [value]
/// changes. If no [value] is provided, every state change is animated.
/// changes.
///
/// [Animated] can be nested, with the closest enclosing [Animated] widget
/// taking precedence.
///
/// To negate the effects of an ancestor [Animated] widget for part of the
/// widget tree, wrap it in an [Animated] widget, with [animation] set to
/// `null`.
///
/// # Examples
///
/// ```dart
Expand Down Expand Up @@ -253,19 +249,15 @@ class Animated extends StatefulWidget {
const Animated({
super.key,
this.animation = const AnimationSpec(),
this.value = _animateAllChanges,
required this.value,
required this.child,
});

static const _animateAllChanges = Object();

/// The [AnimationSpec] to use for animating state changes in descendants.
final AnimationSpec? animation;
final AnimationSpec animation;

/// When this value changes, coinciding state changes in descendants are
/// animated.
///
/// If no value is provided, all state changes are animated.
final Object? value;

/// The widget below this widget in the tree.
Expand All @@ -283,8 +275,7 @@ class _AnimatedState extends State<Animated> {
@override
void didUpdateWidget(covariant Animated oldWidget) {
super.didUpdateWidget(oldWidget);
_animationIsActive = widget.value == Animated._animateAllChanges ||
widget.value != oldWidget.value;
_animationIsActive = widget.value != oldWidget.value;
}

@override
Expand Down

0 comments on commit 9320506

Please sign in to comment.