Last active
June 5, 2020 10:28
-
-
Save SahanAmarsha/d4ddbe1f0445b1f26417d0d18c59ecdb to your computer and use it in GitHub Desktop.
Basic layout for showcase animations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-----* | |
AnimationController _controller; | |
Animation _myAnimation; | |
//*-----initializing animation and animation controller-----* | |
@override | |
void initState() { | |
super.initState(); | |
} | |
@override | |
void dispose() { | |
super.dispose(); | |
//-disposing the animation controller- | |
_controller.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Flutter Animations"), | |
), | |
body: Center( | |
child: | |
Container( | |
width: 250, | |
height: 250, | |
decoration: BoxDecoration( | |
image: new DecorationImage( | |
image: new AssetImage( | |
'assets/images/sample-image.png', | |
) | |
) | |
), | |
) | |
), | |
floatingActionButtonLocation: | |
FloatingActionButtonLocation.centerFloat, | |
floatingActionButton: | |
FloatingActionButton( | |
child: Icon(Icons.play_arrow), | |
onPressed: (){ | |
//*------Enabling the animation-----* | |
_controller.forward(); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment