Skip to content

Instantly share code, notes, and snippets.

@pinkeshdarji
Created May 3, 2019 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinkeshdarji/1787aa67038e170630fcff312e8d90f1 to your computer and use it in GitHub Desktop.
Save pinkeshdarji/1787aa67038e170630fcff312e8d90f1 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class Option5 extends StatefulWidget {
@override
_Option5State createState() => _Option5State();
}
class _Option5State extends State<Option5> with TickerProviderStateMixin {
AlignmentDirectional _ironManAlignment = AlignmentDirectional(0.0, 0.7);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/ibg.png'),
fit: BoxFit.cover)),
),
AnimatedContainer(
duration: Duration(seconds: 3),
alignment: _ironManAlignment,
child: Container(
height: 250,
width: 150,
child: Image.asset('assets/images/ironman.png'),
),
),
Align(
alignment: AlignmentDirectional.bottomCenter,
child: RaisedButton(
onPressed: () {
_flyIronMan();
},
child: Text('Go'),
color: Colors.red,
textColor: Colors.yellowAccent,
shape: BeveledRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
),
)
],
);
}
void _flyIronMan() {
setState(() {
_ironManAlignment = AlignmentDirectional(0.0,-0.7);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment