Flutter Animation Tutorial #7 - Tween Sequences
Key Takeaways
Creates tween sequences in Flutter animations
Full Transcript
southern gang the next step is to make the animation for the pulsating effect whenever we click on this heart right here so i want to grow and shrink it all in one go whenever we click on it and we'll be using the size property to do that so to begin with it's going to be 30 pixels then it's going to grow to 50 when we click on it and then back to 30 again all in one go so this is no longer a linear progression from one value to the next it's from point a to begin with then to b then back to a again all in one go every time we click it so it's going to grow and shrink all within that duration of what is currently i think 500 milliseconds okay so a normal tween won't work because they just have a single begin and a single end value and this time we have three values to tween between we have 30 pixels to 50 pixels and then back to 30 pixels so to achieve this we'll be using a tween sequence so a tween sequence does pretty much what it says it does on the tin it sequences through different tweens so we could have a sequence of three or four tweens lined up next to each other and then when we run the animation it's going to go from one tween to the next to the next to the next so we can start to make more complex animations in our case we're going to have a sequence of two tweens the first one is going to be to grow the heart so from 30 to 50 pixels and then the second tween in the sequence is going to be to shrink it from 50 pixels to 30 pixels again so the first thing i'm going to do is create a new variable up here and that is also going to be an animation object but this time to control the size a bit like this so this right here was for color and in fact you should probably say that it's a color animation right here and also we're going to do another one now so animation this time it's going to be to control a double because we're going to be using a double for this thing right here the size okay so we'll call this size animation all right so now let's create that tween sequence all right so down here underneath where we create the color animation let's also do one this time for the size animation and we're going to set that equal to a tween sequence this time now inside a tween sequence we need a list of tween sequence items so let me go down to the next line and i'm going to say that this list will be of type tween sequence item and then also that is going to be of type double each of those tweens because they're going to return a double to tween between which is going to control the size okay so we're kind of double typing here we have a list right here which is of type tween sequence items so each one of these things is gonna be its own tween sequence item and then each of those is gonna tween a double i hope that makes sense okay so we need two tween sequence items inside this so let me first of all say tween sequence item and then this is gonna be type double and we'll create that so this takes two properties first of all a tween which will dictate where the tween begins and ends and the second property will be the weight which is basically how important this particular tween item is what is the weight of it so let's do the tween first of all so we'll say tween double and then we want this to begin if we can spell this correctly at 30 so that's the initial size and then end at 50. now we also need like i said the weight so let's do that and we'll just split this up so the weight of this is going to be 50 and the other one is going to be 50 so they're equally weighted and the animation spends just the same amount of time on this one as it will the next one okay so that's our first tween sequence item now we need another one which is going to start at 50 and go back to 30. so let me grab this and paste it down here and at this time it's going to begin at 50 and end at 30. and that my friends is all there is to it pretty simple right now i know there's a lot of types here but all we're essentially doing is saying that we have a list of this type right here and inside that list we have individual tween sequence items which are going to give us doubles because remember we're using doubles here to interpolate between two values all right so now we have that tween sequence item we're still getting an error and that's remember because this is not an animation we need to let this be an animation so to do that we call the animate method just as we did up here on the color animation so let me copy that and let's paste it at the bottom down here and now this is an animation and we're just telling our controller to control this animation now so it's going to take 500 milliseconds to go through this tween sequence makes sense okay so now we can use this value the size animation value down here for the size so let's do that underscore size animation dot value like so and if i save this now i'm going to restart the process and it looks like we have a little error there but i think if we restart this should work press over here and if we click on this notice it grow and then shrink and if we click again grow and shrink grow and shrink now i think that is a little bit too long of a duration 500 milliseconds so i'm going to knock this back down to 300 and save that and let's try this again in fact i think we'll need to restart because we've changed up here the state so let me do that and click on one of these again click this and that looks a little nicer okay you could take this down to 200 if you wish entirely up to you so that my friends a tween sequence can be used and the good when we want to combine tweens together one after another as we have done here next up we're going to look at curves
Original Description
Hey gang, in this Flutter animations tutorial we'll take a look at tween sequences in order to string together a more complex animation.
🐱👤🐱👤 JOIN THE GANG -
https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg/join
----------------------------------------
🐱💻 🐱💻 My Udemy Courses:
+ Modern JavaScript - https://www.thenetninja.co.uk/udemy/modern-javascript
+ Vue JS & Firebase - http://www.thenetninja.co.uk/udemy/vue-and-firebase
+ D3.js & Firebase - https://www.thenetninja.co.uk/udemy/d3-and-firebase
🐱💻 🐱💻 Course Files:
+ https://github.com/iamshaunjp/flutter-animations
🐱💻 🐱💻 Other Related Free Courses & Links:
+ Flutter Tutorial for Beginners - https://www.youtube.com/watch?v=1ukSR1GRtMU&list=PL4cUxeGkcC9jLYyp2Aoh6hcWuxFDX6PBJ
+ Flutter & Firebase Tutorial - https://www.youtube.com/watch?v=sfA3NWDBPZ4&list=PL4cUxeGkcC9j--TKIdkb3ISfRbJeJYQwC
+ Get VS Code - https://code.visualstudio.com/
+ Flutter Animation docs - https://flutter.dev/docs/development/ui/animations/overview
🐱💻 🐱💻 Social Links:
Facebook - https://www.facebook.com/thenetninjauk
Twitter - https://twitter.com/thenetninjauk
Instagram - https://www.instagram.com/thenetninja/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Net Ninja · Net Ninja · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
GraphQL Tutorial #5 - Express App Setup
Net Ninja
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
GraphQL Tutorial #8 - Root Query
Net Ninja
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
GraphQL Tutorial #12 - Author Type
Net Ninja
GraphQL Tutorial #13 - Type Relations
Net Ninja
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
GraphQL Tutorial #18 - Mutations
Net Ninja
GraphQL Tutorial #19 - More on Mutations
Net Ninja
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
GraphQL Tutorial #23 - Create React App
Net Ninja
GraphQL Tutorial #24 - Book List Component
Net Ninja
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
GraphQL Tutorial #28 - Add Book Component
Net Ninja
GraphQL Tutorial #29 - External Query File
Net Ninja
GraphQL Tutorial #30 - Updating Component State
Net Ninja
GraphQL Tutorial #31 - Composing Queries
Net Ninja
GraphQL Tutorial #32 - query variables
Net Ninja
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
GraphQL Tutorial #34 - Book Details Component
Net Ninja
GraphQL Tutorial #36 - Styling the App
Net Ninja
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
Updated Vue & Firebase Course (Udemy)
Net Ninja
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja
Related AI Lessons
⚡
⚡
⚡
⚡
Had my Frontend Developer interview with Capgemini (Application Developer) today, and I wanted to…
Medium · JavaScript
10 Frontend Developer Tools to Boost Productivity in 2026
Medium · Programming
10 Frontend Developer Tools to Boost Productivity in 2026
Medium · JavaScript
The US Frontend Engineer Market in 2026: A Data-Driven Reality Check (and the Bias That Stops Us Seeing It)
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI