Skip to content

Instantly share code, notes, and snippets.

@micimize
Created December 25, 2019 17:58
Show Gist options
  • Select an option

  • Save micimize/13327d5a3003dde3730b2aaffd42de7a to your computer and use it in GitHub Desktop.

Select an option

Save micimize/13327d5a3003dde3730b2aaffd42de7a to your computer and use it in GitHub Desktop.
Simple flutter scrim/overlay widget
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