Advanced Physics Based Animations in Dart's Flutter Framework

in #utopian-io6 years ago (edited)

What Will I Learn?

  • You will learn how to build out Physics based Animations in Flutter
  • You will learn how to use Gesture Detection for Animation
  • You will learn about Custom Painters, Paths, the Canvas Object, Scroll Spring Simulation, Offsets and various other Objects from Dart and Flutter

Requirements

Difficulty

  • Advanced

Description

In this tutorial, we look at Physics Based Animation in Dart's Flutter Framework. We do this by making a box that slides up and down and stretches based on the Gestures that the user is making. We use a Gesture detector, Offsets, the ScrollSpringSimulation Object, the CustomPaint Object, the Canvas Object and the Dart UI Path Object. First, we create a Material Application that contains a Scaffold and then we embed a Padding object with a Container inside of it. We then create a Custom Stateful Widget with various properties, namely, a property that tracks where the user is pulling on the box. We then use this information to approximate how our box should react to the user's input. This approximation is not used to directly show how the box is changing but it is used to guide our CustomPainter Object.

We then embed a CustomPainter Object into a Gesture Detector Object which is rendered every frame that the box is being manipulated on. This CustomPainter Object re-renders the box based on the user input using a Canvas and a Dart Path Object. This Dart Path Object allows us to draw out how our animation will look in response to the Gestures by creating a cursor which covers the areas on the box that change. These areas are then rendered every frame to make the animation look smooth. This animation is given the properties of the ScrollSpringSimulation Physics Object which allows it to spring back and forth when the user stops inputting a Gesture.

The source code for this project can be found here

Video Tutorial

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @amosbastian, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Thank you for your hard work and thanks for moderating my content.

Thanks guys.

Nice one,
but can you explain the video in written form, i'm having a hard time watching the video

Which parts are you having issues with?? The flutter mechanics or the actual mathematics behind the animations?

Sorry but i can't play the video at all

Video is on YouTube so if you are having issues playing it then you should probably do so on a different device.

Ok....Thanks

Hey @tensor I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.29
TRX 0.11
JST 0.033
BTC 63901.15
ETH 3133.40
USDT 1.00
SBD 4.05