Skip to content

Instantly share code, notes, and snippets.

View SahanAmarsha's full-sized avatar
🏠
Working from home

Sahan Amarsha SahanAmarsha

🏠
Working from home
View GitHub Profile
@SahanAmarsha
SahanAmarsha / hinge_animation.dart
Created June 10, 2020 13:14
Using the Hinge Animation
body:
AnimatedBuilder(
animation: _slideAnimation,
builder: (ctx, ch) => Container(
width: 200,
height: 100,
padding: EdgeInsets.all(0),
margin: EdgeInsets.only(
left: 75,
top: _slideAnimation.value,
@SahanAmarsha
SahanAmarsha / hinge_animation_controller.dart
Created June 10, 2020 13:04
Defining a Hinge Animation
AnimationController _controller;
Animation _rotateAnimation;
Animation<double> _slideAnimation;
Animation<double> _opacityAnimation;
@override
void initState() {
// TODO: implement initState
super.initState();
@SahanAmarsha
SahanAmarsha / flip_animation.dart
Created June 9, 2020 17:03
Implementing the 3d Flip Animation
body: Center(
child: Transform(
alignment: FractionalOffset.center,
transform: Matrix4.identity()
..setEntry(3, 2, 0.002)
..rotateX(pi*(_myAnimation.value)),
child: Container(
color: Colors.blueAccent,
width: 200,
height: 200,
@SahanAmarsha
SahanAmarsha / flip_animation_controller.dart
Created June 9, 2020 17:01
Defining the Flip Animation
AnimationController _controller;
Animation _myAnimation;
AnimationStatus _animationStatus = AnimationStatus.dismissed;
@override
void initState() {
super.initState();
_controller =
AnimationController(vsync: this, duration: Duration(seconds: 1));
@SahanAmarsha
SahanAmarsha / slide_animation.dart
Created June 5, 2020 11:56
Using the SlideTransition widget to animate
body: Center(
child:
SlideTransition(
position: _myAnimation,
child: const Padding(
padding: EdgeInsets.all(8.0),
child: FlutterLogo(size: 150.0),
),
),
),
@SahanAmarsha
SahanAmarsha / slide_animation_controller.dart
Created June 5, 2020 11:42
Defining a Slide Transition for Flutter App
AnimationController _controller;
Animation<Offset> _myAnimation;
@override
void initState() {
// TODO: implement initState
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
@SahanAmarsha
SahanAmarsha / fade_animation.dart
Created June 5, 2020 10:54
Hot to use Fade Animations in Flutter
body: Center(
child:
FadeTransition(
opacity: _myAnimation,
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
image: new DecorationImage(
image: new AssetImage(
@SahanAmarsha
SahanAmarsha / fade_animation_controller.dart
Last active June 5, 2020 11:20
How to define a fade animation in your Flutter app
AnimationController _controller;
Animation _myAnimation;
void initState() {
// TODO: implement initState
super.initState();
_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 1200),
@SahanAmarsha
SahanAmarsha / heart_animation.dart
Last active June 5, 2020 10:57
How to use heart animation using Animation Buidler Widget
body: Center(
child:
AnimatedBuilder(animation: _myAnimation,
builder: (ctx, ch) => Container(
width: _myAnimation.value.width,
height: _myAnimation.value.height,
decoration: BoxDecoration(
image: new DecorationImage(
image: new AssetImage(
@SahanAmarsha
SahanAmarsha / basic_layout.dart
Last active June 5, 2020 10:28
Basic layout for showcase animations
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin{
//*-----defining animation and animation controller-----*