-
-
Save PoojaB26/f21eb03214174c7ef97efecc3a096c28 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'; | |
class ButtonOpacity extends StatefulWidget { | |
@override | |
ButtonOpacityState createState() { | |
return new ButtonOpacityState(); | |
} | |
} | |
class ButtonOpacityState extends State<ButtonOpacity> { | |
bool _isAdded = false; | |
@override | |
Widget build(BuildContext context) { | |
return InkWell( | |
onTap: () { | |
setState(() { | |
_isAdded = !_isAdded; | |
}); | |
}, | |
child: AnimatedContainer( | |
duration: Duration(milliseconds: 350), | |
curve: Curves.linear, | |
decoration: BoxDecoration( | |
color: _isAdded ? Colors.transparent : Colors.blue, | |
borderRadius: BorderRadius.circular(30), | |
border: Border.all(width: 3.0, color: Colors.blue), | |
), | |
width: _isAdded ? 160 : 60, | |
height: 60, | |
child: Stack( | |
children: <Widget>[ | |
Align( | |
alignment: Alignment.center, | |
child: AnimatedOpacity( | |
duration: Duration(milliseconds: 600), | |
curve: Curves.easeIn, | |
opacity: _isAdded ? 0.0 : 1.0, | |
child: Icon(Icons.person_add, color: Colors.white)), | |
), | |
Align( | |
alignment: Alignment.center, | |
child: AnimatedOpacity( | |
duration: Duration(milliseconds: 550), | |
opacity: _isAdded ? 1.0 : 0.0, | |
child: Text( | |
"MESSAGE", | |
style: TextStyle( | |
fontSize: 18.0, | |
color: Colors.blue, | |
fontWeight: FontWeight.bold), | |
), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment