import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: Animation(),
theme: ThemeData.dark(),
));
}
class Animation extends StatefulWidget {
@override
_AnimationState createState() => _AnimationState();
}
class _AnimationState extends State<Animation> {
double _wi = 20;
double _hi = 35;
double _update() {
setState(() {
_wi = 200;
});
}
double _normal(){
setState(() {
_wi=20;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Animation'),
),
body: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Column(
children: <Widget>[
RaisedButton(
onPressed: () {
_update();
},
child: Text('UPDATE',textScaleFactor: 2,),
),
AnimatedContainer(
duration: Duration(seconds: 2),
width: _wi,
height: _hi,
color: Colors.redAccent,
child: Text(
'WoW',
textScaleFactor: 2,
textAlign: TextAlign.center,
),
),
RaisedButton(
onPressed: () {
_normal();
},
child: Text('BACK',textScaleFactor: 2,),
),
],
),
],
),
);
}
}