Last active
May 3, 2019 13:20
-
-
Save pinkeshdarji/58a83f5d4bacc4e3eb8ee09aa2a2ae29 to your computer and use it in GitHub Desktop.
This file contains 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'; | |
import 'dart:ui'; | |
class Option1 extends StatefulWidget { | |
@override | |
_Option1State createState() => _Option1State(); | |
} | |
class _Option1State extends State<Option1> with TickerProviderStateMixin { | |
Animation<double> animation; | |
AnimationController animationController; | |
@override | |
void initState() { | |
// TODO: implement initState | |
super.initState(); | |
animationController = | |
AnimationController(vsync: this, duration: Duration(seconds: 3)); | |
animation = Tween<double>(begin: 0, end: -300).animate(animationController) | |
..addListener(() { | |
setState(() {}); | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Stack( | |
children: <Widget>[ | |
Container( | |
decoration: BoxDecoration( | |
image: DecorationImage( | |
image: AssetImage('assets/images/ibg.png'), | |
fit: BoxFit.cover)), | |
), | |
Align( | |
alignment: AlignmentDirectional(0,0.7), | |
child: Transform.translate( | |
offset: Offset(0, animation.value), | |
child: Container( | |
height: 250, | |
width: 170, | |
decoration: BoxDecoration( | |
image: DecorationImage( | |
image: AssetImage('assets/images/ironman.png'), | |
)), | |
), | |
), | |
), | |
Align( | |
alignment: AlignmentDirectional.bottomCenter, | |
child: RaisedButton( | |
onPressed: () { | |
animationController.forward(); | |
}, | |
child: Text('Go'), | |
color: Colors.red, | |
textColor: Colors.yellowAccent, | |
shape: BeveledRectangleBorder( | |
borderRadius: BorderRadius.all(Radius.circular(20))), | |
), | |
) | |
], | |
); | |
} | |
@override | |
void dispose() { | |
animationController.dispose(); | |
super.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment