Created
November 16, 2019 04:49
-
-
Save tarek360/b239246310f28c7d3fb628f117de26f8 to your computer and use it in GitHub Desktop.
Flip Widget Vertically or Horizontally.
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
class Flip extends StatelessWidget { | |
final Widget child; | |
final double _scaleX; | |
final double _scaleY; | |
Flip.vertically({@required this.child}) | |
: _scaleX = 1.0, | |
_scaleY = -1.0; | |
Flip.horizontally({@required this.child}) | |
: _scaleX = -1.0, | |
_scaleY = 1.0; | |
@override | |
Widget build(BuildContext context) { | |
return Transform( | |
alignment: Alignment.center, | |
transform: Matrix4.diagonal3Values(_scaleX, _scaleY, 1.0), | |
child: child, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment