SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
Poznan Flutter Developer Group
Bartosz Kosarzycki
Animations in Flutter
1@bkosarzycki
Poznan Flutter Developer Group
Agenda
- Animation types
- Tween animations, physics-based animation
- Animated Container widget
- Animated CrossFade widget
- Hero animation
- Flare overview
- FlareActor, NimaActor
- Expressive animations
2
For animated version of this presentation
click HERE
Poznan Flutter Developer Group
Animation types
- Tween animations
animate value over time
- Physics-based animations
animate in response to user input/movement, animation which include real-world physics
- Animating widgets
help to simplify animations - single responsibility
3
Animations in Flutter ARE INDEPENDENT from widgets
they animate
Poznan Flutter Developer Group
Tween animations
- Short: in-between animations
- start value, end value
- curve [ function: transition over time ]
4
Tween<double>(
begin: 0.0,
end: 5.0,
)
Tween<Position>(
begin: Position(5.0, 10.0),
end: Position(10.0, 15.0),
)
Poznan Flutter Developer Group
Tween animations
5
Poznan Flutter Developer Group
Tween animations
6
ColorTween(
begin: Colors.red,
end: Colors.blue,
)
var colorAnim = ColorTween(
begin: Colors.red,
end: Colors.blue,
).animate(_colorAnimController);
Poznan Flutter Developer Group
7
Poznan Flutter Developer Group
Tween animations - implementation
8
@override
void initState() {
super.initState();
_simpleAnimController = AnimationController(
vsync: this,
duration: Duration(milliseconds:1000))
..addListener(() => setState(() {})
);
_simpleAnim = Tween<double>(
begin: 50,
end: 300,
).animate(_simpleAnimController);
_simpleAnimController.forward();
}
Center(
child: Padding(
padding: EdgeInsets.only(top: _simpleAnim.value),
child: Container(
width: 100,
height: 100,
child: FlutterLogo(),
),
),
class _TweenAnimationPageState extends State<TweenAnimationPage>
with TickerProviderStateMixin {
AnimationController _simpleAnimController;
Animation<double> _simpleAnim;
[...]
Poznan Flutter Developer Group
Tween animations - implementation
9
Poznan Flutter Developer Group
Physics-based animations
10
simulation = ScrollSpringSimulation(
SpringDescription(
mass: 1.0,
stiffness: 1.0,
damping: 1.0,
),
0.0, // start value
1.0, // end value
0.0, // velocity
);
@override
Widget build(BuildContext context) {
return GestureDetector(
onPanStart: startDrag,
onPanUpdate: onDrag,
onPanEnd: endDrag,
child: CustomPaint( // canvas on which to draw during the
paint phase
painter: BoxPainter(
boxPosition: boxPosition,
boxPositionOnStart: boxPositionOnStart ?? boxPosition,
touchPoint: point,
),
child: Container(),
),
);
}
Poznan Flutter Developer Group
Physics-based animations
11
void onDrag(DragUpdateDetails details) {
setState(() {
point = (context.findRenderObject() as RenderBox)
.globalToLocal(details.globalPosition);
final dragVec = start.dy - point.dy;
final normDragVec = (dragVec / context.size.height).clamp(- 1.0, 1.0);
boxPosition = (boxPositionOnStart + normDragVec).clamp( 0.0, 1.0);
});
}
Poznan Flutter Developer Group
Physics-based animations
- RenderBox, RenderObject
- onPanStart(), onPanUpdate(), onPanEnd()
which correspond to startDrag(), onDrag(),
endDrag() [GestureDetector]
- context.findRenderObject() as RenderBox
- DragUpdateDetails, DragStartDetails etc.
-
12
Poznan Flutter Developer Group
Physics library
13
/// Simple one-dimensional physics simulations, such as springs, friction, and
/// gravity, for use in user interface animations.
///
/// To use, import `package:flutter/physics.dart`.
library physics;
export 'src/physics/clamped_simulation.dart' ;
export 'src/physics/friction_simulation.dart' ;
export 'src/physics/gravity_simulation.dart' ;
export 'src/physics/simulation.dart' ;
export 'src/physics/spring_simulation.dart' ;
export 'src/physics/tolerance.dart' ;
export 'src/physics/utils.dart' ;
Poznan Flutter Developer Group
14
No animation object
Poznan Flutter Developer Group
15
Out of the box animations
Stack(children: <Widget>[
new Center(
child: new Container(
decoration: new BoxDecoration(
color: Colors.purple,
),
child: new FlutterLogo(
size: _boxSize,
)),
)
]
var _boxSize = 200.0;
void _startAnimation() {
setState(() {
_boxSize *= 1.3;
});
}
void _resetAnimState() {
setState(() {
_boxSize = 200;
});
}
Poznan Flutter Developer Group
16
Out of the box animations
Simply calling:
setState( () {
…
});
Poznan Flutter Developer Group
Handy animation widgets
17
Poznan Flutter Developer Group
18
AnimatedContainer
AnimatedContainer(
duration: Duration(milliseconds: 2000),
curve: Curves.bounceOut,
width: _boxSize,
height: _boxSize,
decoration: BoxDecoration(
color: Colors.purple,
),
child: FlutterLogo(),
),
var _boxSize = 120.0;
void _startAnimation() {
setState(() {
_boxSize *= 1.7;
});
}
void _resetAnimState() {
setState(() {
_boxSize = 120.0;
});
}
Poznan Flutter Developer Group
19
AnimatedContainer
Main properties
of AnimatedContainer
widget:
- curve
[ function over time /
how the animation behaves]
- duration
[animation duration]
Poznan Flutter Developer Group
20
AnimatedContainer
Properties [of AnimatedContainer] that are null
are not animated. Its child and descendants are
not animated.
Poznan Flutter Developer Group
21
AnimatedContainer
We can also animate more properties automatically, like:
● aligment
● padding
● color
● foregroundDecoration
● constraints [BoxConstraints]
● margin
● transform [Matrix4]; transformation matrix to apply before painting the container
Poznan Flutter Developer Group
22
AnimatedCrossFade
var _rainbowdashImgUrl =
'assets/images/rainbowdash.png' ;
var _dashImgUrl = 'assets/images/dash.png' ;
AnimatedCrossFade(
duration: Duration(milliseconds: 300),
crossFadeState: _animationStarted,
firstChild: Image.asset(_dashImgUrl),
secondChild: Image.asset(_rainbowdashImgUrl),
)
CrossFadeState _animationStarted =
CrossFadeState.showFirst;
void _startAnimation() => setState(() {
_animationStarted =
CrossFadeState.showSecond;
});
void _resetAnimState() => setState(() {
_animationStarted =
CrossFadeState.showFirst;
});
Poznan Flutter Developer Group
23
AnimatedCrossFade
Main properties:
duration - animation length
crossFadeState - triggers the animation
[ enum showFirst, showSecond; ]
Poznan Flutter Developer Group
24
Hero animation
var _dashImgUrl = 'assets/images/dash_s.png';
ListView.builder(
[...]
itemBuilder: (context, position) {
[...]
Hero(
tag: "hero_anim_example_tag" + position.toString(),
child: Container(
width: 70,
child: Image.asset(_dashImgUrl),
),
),
)
Hero(
tag: "hero_anim_example_tag" +
widget.position,
child: Container(
width: double.infinity,
child: Image.asset(_dashImgUrl),
),
),
Poznan Flutter Developer Group
25
Hero animation
Main properties:
tag - identifies specific widget which needs to be
animated across consequent screens
Tag has to be unique in a widget tree!
Poznan Flutter Developer Group
26
Fluttershy / Rainbow Dash
Poznan Flutter Developer Group
27
Flare overview
- Flare is built by 2dimenions.com
- Free for open-source designs
Poznan Flutter Developer Group
28
Flare catalogue
Poznan Flutter Developer Group
29
Flare - edit mode
Poznan Flutter Developer Group
30
Flare - edit mode
- easily import *.svg files
- edit layers, objects, paths
- define animations & states
- infinite loop animations
- basic concepts:
- stage
- nodes
- bones
- animations (design & animate mode)
Poznan Flutter Developer Group
31
Simple Flare animation
import
'package:flare_flutter/flare_actor.dart' ;
var _animationName = "";
bool _isPaused = true;
FlareActor(
"assets/anim/success_check.flr" ,
animation: _animationName,
isPaused: _isPaused,
),
void _startAnimation() => setState(() {
_animationName = "Untitled";
_isPaused = false;
});
void _resetAnimState() => setState(() {
_animationName = "";
_isPaused = true;
});
Poznan Flutter Developer Group
32
FlareActor
Main properties:
filename - *.flr file location [String]
[e.g. ‘assets/anim/example.flr’]
animation - initial animation [String][Optional]
defined inside Flare
isPaused - animation state [Boolean]
Poznan Flutter Developer Group
33
Flare 2d transformations
Poznan Flutter Developer Group
34
Simple Nima animation
import 'package:nima/nima_actor.dart';
var _animationName = "idle";
NimaActor("assets/anim/robot.nma",
alignment: Alignment.center,
animation: _animationName),
)
// 'attack' , 'jump', 'idle'
void _startAnimation() => setState(() {
_animationName = "attack";
});
void _resetAnimState() => setState(() {
_animationName = "idle";
});
void _jumpAnimState() => setState(() {
_animationName = "jump";
});
Poznan Flutter Developer Group
35
NimaActor
Main properties:
filename - *.nma file location [String]
[e.g. ‘assets/anim/example.nma’]
animation - initial animation [String][Optional]
defined inside Nima
Poznan Flutter Developer Group
36
Expressive animations - login experience
Poznan Flutter Developer Group
37
Expressive animations
Poznan Flutter Developer Group
38
Source code
https://github.com/kosiara/flutter-simple-animations
Poznan Flutter Developer Group
References
https://medium.com/flutterpub/widgetoftheweek-animatedcont
ainer-widget-3ebae930ebba
https://docs.2dimensions.com/support/tutorials
https://medium.com/2dimensions/building-an-interactive-login
-screen-with-flare-flutter-749db628bb51
https://docs.2dimensions.com/support/flare/core-concepts
https://medium.com/flutter-io/perspective-on-flutter-6f832f4d9
12e
https://medium.com/flutter-community/make-3d-flip-animation
-in-flutter-16c006bb3798
https://proandroiddev.com/animations-in-flutter-6e02ee91a0b
2
39
https://flutter.dev/docs/development/ui/animations
https://www.youtube.com/watch?v=LHZ0KSvTTqQ
https://proandroiddev.com/getting-your-hands-dirty-with-flutter
-basic-animations-6b9f21fa7d17
Poznan Flutter Developer Group
Summary
Bartosz Kosarzycki
Rafał Ślósarz
Poznań Flutter Developer Group
facebook.com/poznanflutter
40@bkosarzycki

Contenu connexe

Tendances

Developing Cross platform apps in flutter (Android, iOS, Web)
Developing Cross platform apps in flutter (Android, iOS, Web)Developing Cross platform apps in flutter (Android, iOS, Web)
Developing Cross platform apps in flutter (Android, iOS, Web)Priyanka Tyagi
 
Build responsive applications with google flutter
Build responsive applications with  google flutterBuild responsive applications with  google flutter
Build responsive applications with google flutterAhmed Abu Eldahab
 
Build beautiful native apps in record time with flutter
Build beautiful native apps in record time with flutterBuild beautiful native apps in record time with flutter
Build beautiful native apps in record time with flutterRobertLe30
 
What is flutter and why should i care?
What is flutter and why should i care?What is flutter and why should i care?
What is flutter and why should i care?Sergi Martínez
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to heroAhmed Abu Eldahab
 
Introduction to flutter's basic concepts
Introduction to flutter's basic conceptsIntroduction to flutter's basic concepts
Introduction to flutter's basic conceptsKumaresh Chandra Baruri
 
Pune Flutter Presents - Flutter 101
Pune Flutter Presents - Flutter 101Pune Flutter Presents - Flutter 101
Pune Flutter Presents - Flutter 101Arif Amirani
 
Google flutter the easy and practical way
Google flutter the easy and practical wayGoogle flutter the easy and practical way
Google flutter the easy and practical wayAhmed Abu Eldahab
 
The magic of flutter
The magic of flutterThe magic of flutter
The magic of flutterShady Selim
 
Flutter session 01
Flutter session 01Flutter session 01
Flutter session 01DSC IEM
 
Introduction to BOOTSTRAP
Introduction to BOOTSTRAPIntroduction to BOOTSTRAP
Introduction to BOOTSTRAPJeanie Arnoco
 
Build web applications using google flutter
Build web applications using google flutterBuild web applications using google flutter
Build web applications using google flutterAhmed Abu Eldahab
 

Tendances (20)

Developing Cross platform apps in flutter (Android, iOS, Web)
Developing Cross platform apps in flutter (Android, iOS, Web)Developing Cross platform apps in flutter (Android, iOS, Web)
Developing Cross platform apps in flutter (Android, iOS, Web)
 
Flutter
FlutterFlutter
Flutter
 
Build responsive applications with google flutter
Build responsive applications with  google flutterBuild responsive applications with  google flutter
Build responsive applications with google flutter
 
What is Flutter
What is FlutterWhat is Flutter
What is Flutter
 
Build beautiful native apps in record time with flutter
Build beautiful native apps in record time with flutterBuild beautiful native apps in record time with flutter
Build beautiful native apps in record time with flutter
 
What is flutter and why should i care?
What is flutter and why should i care?What is flutter and why should i care?
What is flutter and why should i care?
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to hero
 
Creating Apps with .NET MAUI
Creating Apps with .NET MAUICreating Apps with .NET MAUI
Creating Apps with .NET MAUI
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Introduction to flutter's basic concepts
Introduction to flutter's basic conceptsIntroduction to flutter's basic concepts
Introduction to flutter's basic concepts
 
Pune Flutter Presents - Flutter 101
Pune Flutter Presents - Flutter 101Pune Flutter Presents - Flutter 101
Pune Flutter Presents - Flutter 101
 
Bootstrap Framework
Bootstrap Framework Bootstrap Framework
Bootstrap Framework
 
Bootstrap 5 basic
Bootstrap 5 basicBootstrap 5 basic
Bootstrap 5 basic
 
Google flutter the easy and practical way
Google flutter the easy and practical wayGoogle flutter the easy and practical way
Google flutter the easy and practical way
 
The magic of flutter
The magic of flutterThe magic of flutter
The magic of flutter
 
Flutter session 01
Flutter session 01Flutter session 01
Flutter session 01
 
Introduction to BOOTSTRAP
Introduction to BOOTSTRAPIntroduction to BOOTSTRAP
Introduction to BOOTSTRAP
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
Build web applications using google flutter
Build web applications using google flutterBuild web applications using google flutter
Build web applications using google flutter
 

Similaire à Animations in Flutter

Getting started with Verold and Three.js
Getting started with Verold and Three.jsGetting started with Verold and Three.js
Getting started with Verold and Three.jsVerold
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconftutorialsruby
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconftutorialsruby
 
How to Animate a Widget Across Screens in Flutter.pptx
How to Animate a Widget Across Screens in Flutter.pptxHow to Animate a Widget Across Screens in Flutter.pptx
How to Animate a Widget Across Screens in Flutter.pptxFlutter Agency
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 MinigamesSusan Gold
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreRemy Sharp
 
Stop running from animations droidcon London
Stop running from animations droidcon LondonStop running from animations droidcon London
Stop running from animations droidcon Londonmaric_iv
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkJussi Pohjolainen
 
Desenvolva um game para android ou iPhone
Desenvolva um game para android ou iPhoneDesenvolva um game para android ou iPhone
Desenvolva um game para android ou iPhoneTiago Oliveira
 
React native introduction
React native introductionReact native introduction
React native introductionInnerFood
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2dVinsol
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersJiaxuan Lin
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxyginecorehard_by
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-senseBen Lin
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...Publicis Sapient Engineering
 

Similaire à Animations in Flutter (20)

Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
Getting started with Verold and Three.js
Getting started with Verold and Three.jsGetting started with Verold and Three.js
Getting started with Verold and Three.js
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
 
How to Animate a Widget Across Screens in Flutter.pptx
How to Animate a Widget Across Screens in Flutter.pptxHow to Animate a Widget Across Screens in Flutter.pptx
How to Animate a Widget Across Screens in Flutter.pptx
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
 
Unity3 d devfest-2014
Unity3 d devfest-2014Unity3 d devfest-2014
Unity3 d devfest-2014
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
Stop running from animations droidcon London
Stop running from animations droidcon LondonStop running from animations droidcon London
Stop running from animations droidcon London
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation Framework
 
React native
React nativeReact native
React native
 
Desenvolva um game para android ou iPhone
Desenvolva um game para android ou iPhoneDesenvolva um game para android ou iPhone
Desenvolva um game para android ou iPhone
 
Flex 4 tips
Flex 4 tipsFlex 4 tips
Flex 4 tips
 
React native introduction
React native introductionReact native introduction
React native introduction
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxygine
 
Revolver
RevolverRevolver
Revolver
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-sense
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
 

Plus de Bartosz Kosarzycki

Droidcon Online 2020 quick summary
Droidcon Online 2020 quick summaryDroidcon Online 2020 quick summary
Droidcon Online 2020 quick summaryBartosz Kosarzycki
 
Flutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for businessFlutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for businessBartosz Kosarzycki
 
Flutter CI & Device Farms for Flutter
Flutter CI & Device Farms for FlutterFlutter CI & Device Farms for Flutter
Flutter CI & Device Farms for FlutterBartosz Kosarzycki
 
Drone racing - beginner's guide
Drone racing - beginner's guideDrone racing - beginner's guide
Drone racing - beginner's guideBartosz Kosarzycki
 
Optimize apps for Chromebooks - Meet.Intive Oct, 2018
Optimize apps for Chromebooks - Meet.Intive Oct, 2018Optimize apps for Chromebooks - Meet.Intive Oct, 2018
Optimize apps for Chromebooks - Meet.Intive Oct, 2018Bartosz Kosarzycki
 
Android - Gradle build optimisation 3d83f31339d239abcc55f869e5f30348?s=47
Android - Gradle build optimisation  3d83f31339d239abcc55f869e5f30348?s=47Android - Gradle build optimisation  3d83f31339d239abcc55f869e5f30348?s=47
Android - Gradle build optimisation 3d83f31339d239abcc55f869e5f30348?s=47Bartosz Kosarzycki
 
Android things introduction - Development for IoT
Android things introduction - Development for IoTAndroid things introduction - Development for IoT
Android things introduction - Development for IoTBartosz Kosarzycki
 
Daggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processorDaggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processorBartosz Kosarzycki
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastBartosz Kosarzycki
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requestsBartosz Kosarzycki
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersBartosz Kosarzycki
 
Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersBartosz Kosarzycki
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsBartosz Kosarzycki
 

Plus de Bartosz Kosarzycki (18)

Droidcon Summary 2021
Droidcon Summary 2021Droidcon Summary 2021
Droidcon Summary 2021
 
Droidcon Online 2020 quick summary
Droidcon Online 2020 quick summaryDroidcon Online 2020 quick summary
Droidcon Online 2020 quick summary
 
Provider vs BLoC vs Redux
Provider vs BLoC vs ReduxProvider vs BLoC vs Redux
Provider vs BLoC vs Redux
 
Flutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for businessFlutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for business
 
Flutter CI & Device Farms for Flutter
Flutter CI & Device Farms for FlutterFlutter CI & Device Farms for Flutter
Flutter CI & Device Farms for Flutter
 
Drone racing - beginner's guide
Drone racing - beginner's guideDrone racing - beginner's guide
Drone racing - beginner's guide
 
Optimize apps for Chromebooks - Meet.Intive Oct, 2018
Optimize apps for Chromebooks - Meet.Intive Oct, 2018Optimize apps for Chromebooks - Meet.Intive Oct, 2018
Optimize apps for Chromebooks - Meet.Intive Oct, 2018
 
Android - Gradle build optimisation 3d83f31339d239abcc55f869e5f30348?s=47
Android - Gradle build optimisation  3d83f31339d239abcc55f869e5f30348?s=47Android - Gradle build optimisation  3d83f31339d239abcc55f869e5f30348?s=47
Android - Gradle build optimisation 3d83f31339d239abcc55f869e5f30348?s=47
 
DroidCon Berlin 2018 summary
DroidCon Berlin 2018 summaryDroidCon Berlin 2018 summary
DroidCon Berlin 2018 summary
 
SCALA - Functional domain
SCALA -  Functional domainSCALA -  Functional domain
SCALA - Functional domain
 
Android things introduction - Development for IoT
Android things introduction - Development for IoTAndroid things introduction - Development for IoT
Android things introduction - Development for IoT
 
Daggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processorDaggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processor
 
Android antipatterns
Android antipatternsAndroid antipatterns
Android antipatterns
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fast
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requests
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
 
Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developers
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projects
 

Dernier

Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 

Dernier (20)

Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 

Animations in Flutter

  • 1. Poznan Flutter Developer Group Bartosz Kosarzycki Animations in Flutter 1@bkosarzycki
  • 2. Poznan Flutter Developer Group Agenda - Animation types - Tween animations, physics-based animation - Animated Container widget - Animated CrossFade widget - Hero animation - Flare overview - FlareActor, NimaActor - Expressive animations 2 For animated version of this presentation click HERE
  • 3. Poznan Flutter Developer Group Animation types - Tween animations animate value over time - Physics-based animations animate in response to user input/movement, animation which include real-world physics - Animating widgets help to simplify animations - single responsibility 3 Animations in Flutter ARE INDEPENDENT from widgets they animate
  • 4. Poznan Flutter Developer Group Tween animations - Short: in-between animations - start value, end value - curve [ function: transition over time ] 4 Tween<double>( begin: 0.0, end: 5.0, ) Tween<Position>( begin: Position(5.0, 10.0), end: Position(10.0, 15.0), )
  • 5. Poznan Flutter Developer Group Tween animations 5
  • 6. Poznan Flutter Developer Group Tween animations 6 ColorTween( begin: Colors.red, end: Colors.blue, ) var colorAnim = ColorTween( begin: Colors.red, end: Colors.blue, ).animate(_colorAnimController);
  • 8. Poznan Flutter Developer Group Tween animations - implementation 8 @override void initState() { super.initState(); _simpleAnimController = AnimationController( vsync: this, duration: Duration(milliseconds:1000)) ..addListener(() => setState(() {}) ); _simpleAnim = Tween<double>( begin: 50, end: 300, ).animate(_simpleAnimController); _simpleAnimController.forward(); } Center( child: Padding( padding: EdgeInsets.only(top: _simpleAnim.value), child: Container( width: 100, height: 100, child: FlutterLogo(), ), ), class _TweenAnimationPageState extends State<TweenAnimationPage> with TickerProviderStateMixin { AnimationController _simpleAnimController; Animation<double> _simpleAnim; [...]
  • 9. Poznan Flutter Developer Group Tween animations - implementation 9
  • 10. Poznan Flutter Developer Group Physics-based animations 10 simulation = ScrollSpringSimulation( SpringDescription( mass: 1.0, stiffness: 1.0, damping: 1.0, ), 0.0, // start value 1.0, // end value 0.0, // velocity ); @override Widget build(BuildContext context) { return GestureDetector( onPanStart: startDrag, onPanUpdate: onDrag, onPanEnd: endDrag, child: CustomPaint( // canvas on which to draw during the paint phase painter: BoxPainter( boxPosition: boxPosition, boxPositionOnStart: boxPositionOnStart ?? boxPosition, touchPoint: point, ), child: Container(), ), ); }
  • 11. Poznan Flutter Developer Group Physics-based animations 11 void onDrag(DragUpdateDetails details) { setState(() { point = (context.findRenderObject() as RenderBox) .globalToLocal(details.globalPosition); final dragVec = start.dy - point.dy; final normDragVec = (dragVec / context.size.height).clamp(- 1.0, 1.0); boxPosition = (boxPositionOnStart + normDragVec).clamp( 0.0, 1.0); }); }
  • 12. Poznan Flutter Developer Group Physics-based animations - RenderBox, RenderObject - onPanStart(), onPanUpdate(), onPanEnd() which correspond to startDrag(), onDrag(), endDrag() [GestureDetector] - context.findRenderObject() as RenderBox - DragUpdateDetails, DragStartDetails etc. - 12
  • 13. Poznan Flutter Developer Group Physics library 13 /// Simple one-dimensional physics simulations, such as springs, friction, and /// gravity, for use in user interface animations. /// /// To use, import `package:flutter/physics.dart`. library physics; export 'src/physics/clamped_simulation.dart' ; export 'src/physics/friction_simulation.dart' ; export 'src/physics/gravity_simulation.dart' ; export 'src/physics/simulation.dart' ; export 'src/physics/spring_simulation.dart' ; export 'src/physics/tolerance.dart' ; export 'src/physics/utils.dart' ;
  • 14. Poznan Flutter Developer Group 14 No animation object
  • 15. Poznan Flutter Developer Group 15 Out of the box animations Stack(children: <Widget>[ new Center( child: new Container( decoration: new BoxDecoration( color: Colors.purple, ), child: new FlutterLogo( size: _boxSize, )), ) ] var _boxSize = 200.0; void _startAnimation() { setState(() { _boxSize *= 1.3; }); } void _resetAnimState() { setState(() { _boxSize = 200; }); }
  • 16. Poznan Flutter Developer Group 16 Out of the box animations Simply calling: setState( () { … });
  • 17. Poznan Flutter Developer Group Handy animation widgets 17
  • 18. Poznan Flutter Developer Group 18 AnimatedContainer AnimatedContainer( duration: Duration(milliseconds: 2000), curve: Curves.bounceOut, width: _boxSize, height: _boxSize, decoration: BoxDecoration( color: Colors.purple, ), child: FlutterLogo(), ), var _boxSize = 120.0; void _startAnimation() { setState(() { _boxSize *= 1.7; }); } void _resetAnimState() { setState(() { _boxSize = 120.0; }); }
  • 19. Poznan Flutter Developer Group 19 AnimatedContainer Main properties of AnimatedContainer widget: - curve [ function over time / how the animation behaves] - duration [animation duration]
  • 20. Poznan Flutter Developer Group 20 AnimatedContainer Properties [of AnimatedContainer] that are null are not animated. Its child and descendants are not animated.
  • 21. Poznan Flutter Developer Group 21 AnimatedContainer We can also animate more properties automatically, like: ● aligment ● padding ● color ● foregroundDecoration ● constraints [BoxConstraints] ● margin ● transform [Matrix4]; transformation matrix to apply before painting the container
  • 22. Poznan Flutter Developer Group 22 AnimatedCrossFade var _rainbowdashImgUrl = 'assets/images/rainbowdash.png' ; var _dashImgUrl = 'assets/images/dash.png' ; AnimatedCrossFade( duration: Duration(milliseconds: 300), crossFadeState: _animationStarted, firstChild: Image.asset(_dashImgUrl), secondChild: Image.asset(_rainbowdashImgUrl), ) CrossFadeState _animationStarted = CrossFadeState.showFirst; void _startAnimation() => setState(() { _animationStarted = CrossFadeState.showSecond; }); void _resetAnimState() => setState(() { _animationStarted = CrossFadeState.showFirst; });
  • 23. Poznan Flutter Developer Group 23 AnimatedCrossFade Main properties: duration - animation length crossFadeState - triggers the animation [ enum showFirst, showSecond; ]
  • 24. Poznan Flutter Developer Group 24 Hero animation var _dashImgUrl = 'assets/images/dash_s.png'; ListView.builder( [...] itemBuilder: (context, position) { [...] Hero( tag: "hero_anim_example_tag" + position.toString(), child: Container( width: 70, child: Image.asset(_dashImgUrl), ), ), ) Hero( tag: "hero_anim_example_tag" + widget.position, child: Container( width: double.infinity, child: Image.asset(_dashImgUrl), ), ),
  • 25. Poznan Flutter Developer Group 25 Hero animation Main properties: tag - identifies specific widget which needs to be animated across consequent screens Tag has to be unique in a widget tree!
  • 26. Poznan Flutter Developer Group 26 Fluttershy / Rainbow Dash
  • 27. Poznan Flutter Developer Group 27 Flare overview - Flare is built by 2dimenions.com - Free for open-source designs
  • 28. Poznan Flutter Developer Group 28 Flare catalogue
  • 29. Poznan Flutter Developer Group 29 Flare - edit mode
  • 30. Poznan Flutter Developer Group 30 Flare - edit mode - easily import *.svg files - edit layers, objects, paths - define animations & states - infinite loop animations - basic concepts: - stage - nodes - bones - animations (design & animate mode)
  • 31. Poznan Flutter Developer Group 31 Simple Flare animation import 'package:flare_flutter/flare_actor.dart' ; var _animationName = ""; bool _isPaused = true; FlareActor( "assets/anim/success_check.flr" , animation: _animationName, isPaused: _isPaused, ), void _startAnimation() => setState(() { _animationName = "Untitled"; _isPaused = false; }); void _resetAnimState() => setState(() { _animationName = ""; _isPaused = true; });
  • 32. Poznan Flutter Developer Group 32 FlareActor Main properties: filename - *.flr file location [String] [e.g. ‘assets/anim/example.flr’] animation - initial animation [String][Optional] defined inside Flare isPaused - animation state [Boolean]
  • 33. Poznan Flutter Developer Group 33 Flare 2d transformations
  • 34. Poznan Flutter Developer Group 34 Simple Nima animation import 'package:nima/nima_actor.dart'; var _animationName = "idle"; NimaActor("assets/anim/robot.nma", alignment: Alignment.center, animation: _animationName), ) // 'attack' , 'jump', 'idle' void _startAnimation() => setState(() { _animationName = "attack"; }); void _resetAnimState() => setState(() { _animationName = "idle"; }); void _jumpAnimState() => setState(() { _animationName = "jump"; });
  • 35. Poznan Flutter Developer Group 35 NimaActor Main properties: filename - *.nma file location [String] [e.g. ‘assets/anim/example.nma’] animation - initial animation [String][Optional] defined inside Nima
  • 36. Poznan Flutter Developer Group 36 Expressive animations - login experience
  • 37. Poznan Flutter Developer Group 37 Expressive animations
  • 38. Poznan Flutter Developer Group 38 Source code https://github.com/kosiara/flutter-simple-animations
  • 39. Poznan Flutter Developer Group References https://medium.com/flutterpub/widgetoftheweek-animatedcont ainer-widget-3ebae930ebba https://docs.2dimensions.com/support/tutorials https://medium.com/2dimensions/building-an-interactive-login -screen-with-flare-flutter-749db628bb51 https://docs.2dimensions.com/support/flare/core-concepts https://medium.com/flutter-io/perspective-on-flutter-6f832f4d9 12e https://medium.com/flutter-community/make-3d-flip-animation -in-flutter-16c006bb3798 https://proandroiddev.com/animations-in-flutter-6e02ee91a0b 2 39 https://flutter.dev/docs/development/ui/animations https://www.youtube.com/watch?v=LHZ0KSvTTqQ https://proandroiddev.com/getting-your-hands-dirty-with-flutter -basic-animations-6b9f21fa7d17
  • 40. Poznan Flutter Developer Group Summary Bartosz Kosarzycki Rafał Ślósarz Poznań Flutter Developer Group facebook.com/poznanflutter 40@bkosarzycki