Rafael Almeida Barbosa
Desenvolvedor Mobile, Palestrante, Pai coruja! Apaixonado por inovações e soluções que cabem na palma da mão!
Entendendo animações explícitas e implícitas
Rafael Almeida Barbosa
Android/Flutter Developer - CEO Boleiro
1 - 35
2 - 35
Max Wertheimer
1912
3 - 35
Porque utiliza-las?
Issara Willenskomer
Felippe Silveira
4 - 35
Explícitas
Implícitas
5 - 35
6 - 35
7 - 35
_controller = AnimationController(
vsync: this, // the SingleTickerProviderStateMixin
duration: Duration(seconds: 2),
);
_controller.forward();
_controller.reverse();
8 - 35
_animation = Tween<Offset>(
begin: const Offset(100.0, 50.0),
end: const Offset(200.0, 300.0),
).animate(_controller);
9 - 35
(AnimatedWidget)
10 - 35
@override
void initState() {
super.initState();
_controller =
AnimationController(vsync: this, duration: Duration(seconds: 2));
_controller.forward();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: FadeTransition(
opacity: _controller,
child: Center(
child: Container(
width: 100.0,
height: 100.0,
color: Colors.blue,
)
),
),
);
}
11 - 35
12 - 35
@override
void initState() {
super.initState();
_controller =
AnimationController(vsync: this, duration: Duration(seconds: 2));
_controller.forward();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: ScaleTransition(
scale: _controller,
child: Center(
child: Container(
width: 100.0,
height: 100.0,
color: Colors.blue,
)
),
),
);
}
13 - 35
14 - 35
@override
void initState() {
super.initState();
_controller =
AnimationController(vsync: this, duration: Duration(seconds: 2));
_controller.forward();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: RotationTransition(
turns: _controller,
child: Center(
child: Container(
width: 100.0,
height: 100.0,
color: Colors.blue,
)
),
),
);
}
15 - 35
16 - 35
@override
Widget build(BuildContext context) {
return Scaffold(
body: FadeTransition(
opacity: _controller,
child: ScaleTransition(
scale: _controller,
child: Center(
child: InkWell(
onTap: (){
_controller.forward(from: 0.0);
},
child: Container(
width: 100.0,
height: 100.0,
color: Colors.blue,
),
)
),
),
),
);
}
17 - 35
18 - 35
_animation = Tween(begin: -1.0, end: 0.0).animate(CurvedAnimation(
parent: _controller,
curve: Curves.fastOutSlowIn,
));
....
final double width = MediaQuery.of(context).size.width;
return Scaffold(
body: AnimatedBuilder(
animation: _controller,
builder: (BuildContext context, Widget child) {
return Transform(
transform:
Matrix4.translationValues(_animation.value * width, 0.0, 0.0),
child: child,
);
},
child: new Center(
child: Container(
width: 100.0,
height: 100.0,
color: Colors.blue,
)
),
),
);
19 - 35
20 - 35
(ImplicitlyAnimatedWidget)
21 - 35
double paddingVertical = 20.0;
double paddingHorizontal = 50.0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: AnimatedPadding(
duration: Duration(seconds: 1),
padding: EdgeInsets.only(right: paddingHorizontal,left: paddingHorizontal,
top: paddingVertical,bottom: paddingVertical),
child: InkWell(
onTap: (){
setState(() {
paddingVertical = 200.0;
paddingHorizontal = 20.0;
});
},
child: Container(
color: Colors.blue,
),
),
),
);
}
22 - 35
23 - 35
double paddingVertical = 20.0;
double paddingHorizontal = 50.0;
Color color = Colors.blue;
double axisX = -100;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: AnimatedContainer(
duration: Duration(seconds: 1),
color: color,
padding: EdgeInsets.only(right: paddingHorizontal,left: paddingHorizontal,
top: paddingVertical,bottom: paddingVertical),
transform: Matrix4.translationValues(axisX, 0.0, 0.0),
child: InkWell(
onTap: (){
setState(() {
color = Colors.red;
paddingVertical = 80.0;
paddingHorizontal = 20.0;
axisX = 0.0;
});
},
child: Container(
width: 100,
height: 100,
),
),
),
),
);
}
24 - 35
24 - 35
Widget build(BuildContext context) {
return SizedBox(
width: width,
child: Hero(
tag: photo,
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
child: Image.asset(
photo,
fit: BoxFit.contain,
),
),
),
),
);
}
24 - 35
24 - 35
24 - 35
24 - 35
24 - 35
Obrigado!
GithubPage: http://rafaelbarbosatec.github.io
LInkedln: https://www.linkedin.com/in/rafael-almeida-7667a063
Medium: @rafaelbarbosatec
By Rafael Almeida Barbosa
Desenvolvedor Mobile, Palestrante, Pai coruja! Apaixonado por inovações e soluções que cabem na palma da mão!