Skip to content

Instantly share code, notes, and snippets.

@av
Created January 13, 2020 17:28
Show Gist options
  • Save av/4fc327e7aa803c2f7beb1f21b6b86940 to your computer and use it in GitHub Desktop.
Save av/4fc327e7aa803c2f7beb1f21b6b86940 to your computer and use it in GitHub Desktop.
Flutter: neu
class NeumorphicContainer extends StatelessWidget {
// ...
// New property, will store overridden color
// if passed from outside
final Color color;
NeumorphicContainer({
Key key,
this.child,
this.bevel = 10.0,
// We can't initiailize it with default background here, unless we
// know it aforehead and don't bother with dynamic themes.
this.color,
}) : this.blurOffset = Offset(bevel / 2, bevel / 2),
super(key: key);
@override
Widget build(BuildContext context) {
// We'll use either provided color, or color from theme.
final color = this.color ?? Theme.of(context).backgroundColor;
return Container(...);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment