Skip to content

Instantly share code, notes, and snippets.

@tarek360
Created November 16, 2019 04:49
Show Gist options
  • Save tarek360/b239246310f28c7d3fb628f117de26f8 to your computer and use it in GitHub Desktop.
Save tarek360/b239246310f28c7d3fb628f117de26f8 to your computer and use it in GitHub Desktop.
Flip Widget Vertically or Horizontally.
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