返回介绍

Introduction to animations

发布于 2019-12-09 21:31:22 字数 7666 浏览 867 评论 0 收藏 0

  • Common animation patterns
  • Other resources
  • Well-designed animations makes a UI feel more intuitive, contribute to the slick look and feel of a polished app, and improve the user experience. Flutter’s animation support makes it easy to implement a variety of animation types. Many widgets, especially Material widgets, come with the standard motion effects defined in their design spec, but it’s also possible to customize these effects.

    The following resources are a good place to start learning the Flutter animation framework. Each of these documents shows, step by step, how to write animation code.

    We also have some videos that discuss aspects of Flutter animation.

    AnimatedContainer

    Opacity, including the implicit AnimatedOpacity widget

    FadeInImage

    Hero

    Transform

    AnimatedBuilder

    Animation types

    Animations fall into one of two categories: tween- or physics-based. The following sections explain what these terms mean, and points you to resources where you can learn more. In some cases, the best documentation we currently have is example code in the Flutter gallery.

    Tween animation

    Short for in-betweening. In a tween animation, the beginning and ending points are defined, as well as a timeline, and a curve that defines the timing and speed of the transition. The framework calculates how to transition from the beginning point to the end point.

    The documents listed above, such as the animations tutorial are not about tweening, specifically, but they use tweens in their examples.

    Physics-based animation

    In physics-based animation, motion is modeled to resemble real-world behavior. When you toss a ball, for example, where and when it lands depends on how fast it was tossed and how far it was from the ground. Similarly, dropping a ball attached to a spring falls (and bounces) differently than dropping a ball attached to a string.

    Common animation patterns

    Most UX or motion designers find that certain animation patterns are used repeatedly when designing a UI. This section lists some of the commonly used animation patterns, and tells you where you can learn more.

    Animated list or grid

    This pattern involves animating the addition or removal of elements from a list or grid.

    • AnimatedList example
      This demo, from the Sample App Catalog, shows how to animate adding an element to a list, or removing a selected element. The internal Dart list is synced as the user modifies the list using the plus (+) and minus (-) buttons.

    Shared element transition

    In this pattern, the user selects an element—often an image—from the page, and the UI animates the selected element to a new page with more detail. In Flutter, you can easily implement shared element transitions between routes (pages) using the Hero widget.

    • Hero Animations How to create two styles of Hero animations:
      • The hero flies from one page to another while changing position and size.
      • The hero’s boundary changes shape, from a circle to a square, as its flies from one page to another.
    • Flutter Gallery
      You can build the Gallery app yourself, or download it from the Play Store. The Shrine demo includes an example of a Hero animation.

    • Also see the API documentation for the Hero, Navigator, and PageRoute classes.

    Staggered animation

    Animations that are broken into smaller motions, where some of the motion is delayed. The smaller animations may be sequential, or may partially or completely overlap.

    Other resources

    Learn more about Flutter animations at the following links:


    If there is specific animation documentation you’d like to see, file an issue.

    如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
    列表为空,暂无数据
      我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
      原文