Flutter随笔

translations.dart阅读

2020-09-17  本文已影响0人  嘛尼嘛哄

AnimatedWidget


_AnimatedState
....
  @override
  Widget build(BuildContext context) => widget.build(context);


AnimatedWidget
....
  @protected
  Widget build(BuildContext context);

 
class AnimatedBuilder extends AnimatedWidget
....
 @override
  Widget build(BuildContext context) {
    return builder(context, child);
  }

总结: 子类重写父类的build方法,父类完成 animtaion value change事件的绑定,子类在 build方法触发时根据当前的animation value来更新界面。 基于这个套路, 还有如下的相关Widget:
/// ## Common animated widgets
///
/// A number of animated widgets ship with the framework. They are usually named
/// FooTransition, where Foo is the name of the non-animated
/// version of that widget. The subclasses of this class should not be confused
/// with subclasses of [ImplicitlyAnimatedWidget] (see above), which are usually
/// named AnimatedFoo. Commonly used animated widgets include:
///
/// * [AnimatedBuilder], which is useful for complex animation use cases and a
/// notable exception to the naming scheme of [AnimatedWidget] subclasses.
/// * [AlignTransition], which is an animated version of [Align].
/// * [DecoratedBoxTransition], which is an animated version of [DecoratedBox].
/// * [DefaultTextStyleTransition], which is an animated version of
/// [DefaultTextStyle].
/// * [PositionedTransition], which is an animated version of [Positioned].
/// * [RelativePositionedTransition], which is an animated version of
/// [Positioned].
/// * [RotationTransition], which animates the rotation of a widget.
/// * [ScaleTransition], which animates the scale of a widget.
/// * [SizeTransition], which animates its own size.
/// * [SlideTransition], which animates the position of a widget relative to
/// its normal position.
/// * [FadeTransition], which is an animated version of [Opacity].
/// * [AnimatedModalBarrier], which is an animated version of [ModalBarrier].

上一篇 下一篇

猜你喜欢

热点阅读