美文网首页Flutter随笔
translations.dart阅读

translations.dart阅读

作者: 嘛尼嘛哄 | 来源:发表于2020-09-17 08:33 被阅读0次

AnimatedWidget

  • 它是一个StatefulWidget, 初始化传入一个Listenable
  • 通过Listenable内部绑定了setState方法去触发子类的 build方法.
  • 子类通过继承AnimatedWidget,通过传入的Animation就能触发build方法
  • 以AnimateBuilder为例:

_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].

  • 从上面的名字上来看,基本都是对Widget进行了一次包装, 命名上在原来的Widget后面加上了Translation.

相关文章

  • translations.dart阅读

    AnimatedWidget 它是一个StatefulWidget, 初始化传入一个Listenable 通过Li...

  • 阅读是一件非常重要的小事

    坚持阅读,坚持阅读,坚持阅读,坚持阅读,坚持阅读,坚持阅读,坚持阅读,坚持阅读,坚持阅读,坚持阅读,坚持阅读,坚持...

  • 阅读、阅读、还是阅读

    阅读、阅读、还是阅读 ——第十二周给海螺们的一封信 亲爱的大海螺、小海螺们 周末好! 今天,是第十二周的末端,距离...

  • 阅读,阅读,还是阅读。

    中国古代宋真宗的《励学篇》写到:“富家不用买良田,书中自有千钟粟。安居不用架高楼,书中自有黄金屋。娶妻莫恨...

  • 阅读,阅读,再阅读……

    苏联数育家苏霍姆林斯基曾说过“让孩子变聪明的方法,不是补课,不是增加作业量,而是阅读,阅读,再阅读。” 如果说文化...

  • 阅读—阅读—再阅读

    突然想知道背诵作文到底是对是错? 也许家长或老师的出发点并没有对错之分,他们都寄希望于每个孩子都能学习更多知识。不...

  • 【文魁大脑读书会2016】杜星默 第本7/52《如何阅读一本书》

    阅读目的:学习阅读 阅读方法:检视阅读 笔记: 阅读的四个层次:基础阅读,检视阅读,分析阅读和主题阅读。 检视阅读...

  • 阅读、阅读……

    弘扬中华优秀传统文化,与阅读同行,启迪大脑潜能,提升综合素养,从小培养孩子的读书习惯,润育生命,智慧人生。 ...

  • 阅读,阅读

    临近期末,很多家长都问我孩子的成绩问题,并且发愁。比如,阅读理解题和看图写话不好,很拉分怎么办?周末一大早,我们来...

  • 阅读?阅读!

    “语文老师,我们班主任从这周开始不让我们借书了。” “为什么?” “怕耽误学习呗!” “你们晚上延时的时间是让学生...

网友评论

    本文标题:translations.dart阅读

    本文链接:https://www.haomeiwen.com/subject/fmgvektx.html