Created
December 25, 2019 17:58
-
-
Save micimize/13327d5a3003dde3730b2aaffd42de7a to your computer and use it in GitHub Desktop.
Simple flutter scrim/overlay widget
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 Scrim extends StatelessWidget { | |
| final bool applied; | |
| final Widget child; | |
| final double opacity; | |
| final Duration speed; | |
| final Color color; | |
| const Scrim({ | |
| Key key, | |
| this.applied, | |
| this.child, | |
| this.opacity = 0.75, | |
| this.color = Colors.white, | |
| this.speed = const Duration(milliseconds: 200), | |
| }) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { | |
| return AbsorbPointer( | |
| absorbing: applied, | |
| child: AnimatedContainer( | |
| duration: speed, | |
| curve: const Interval(0.0, 0.4, curve: Curves.easeInOut), | |
| foregroundDecoration: BoxDecoration( | |
| color: color.withOpacity(applied ? opacity : 0.0), | |
| ), | |
| child: child, | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment