Created
January 13, 2020 16:13
-
-
Save av/9ed44aae4a5075ab76010d759d87a7e1 to your computer and use it in GitHub Desktop.
Flutter: neu
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 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