This file contains 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
// Converting NeumorphicContainer to a StatefulWidget | |
class NeumorphicContainer extends StatefulWidget { | |
final Widget child; | |
final double bevel; | |
final Offset blurOffset; | |
final Color color; | |
NeumorphicContainer({ | |
Key key, | |
this.child, |
This file contains 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
gradient: LinearGradient( | |
begin: Alignment.topLeft, | |
end: Alignment.bottomRight, | |
colors: [ | |
color.mix(Colors.black, .1), | |
color, | |
color, | |
color.mix(Colors.white, .5), | |
], | |
stops: [ |
This file contains 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
// ... | |
padding: const EdgeInsets.all(24.0), | |
// ... |
This file contains 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
// In NeumorphicContainer.build > Container > BoxDecoration | |
// ... | |
gradient: LinearGradient( | |
begin: Alignment.topLeft, | |
end: Alignment.bottomRight, | |
colors: [ | |
color.mix(Colors.white, .2), | |
color.mix(Colors.black, .1), | |
] | |
), |
This file contains 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
// In NeumorphicContainer.build > Container > BoxShadow | |
// Mixing with white | |
color: color.mix(Colors.white, .6), | |
// ... | |
// Mixing with black | |
color: color.mix(Colors.black, .3), | |
// ... |
This file contains 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 file contains 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 file contains 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
// In NeumorphicApp.build > MaterialApp > ThemeData | |
// ... | |
backgroundColor: Colors.blueGrey.shade200, | |
scaffoldBackgroundColor: Colors.blueGrey.shade200, | |
dialogBackgroundColor: Colors.blueGrey.shade200, | |
// ... |
This file contains 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
extension ColorUtils on Color { | |
Color mix(Color another, double amount) { | |
return Color.lerp(this, another, amount); | |
} | |
} |
This file contains 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
// In NeumorphicApp | |
// ... | |
home: Scaffold( | |
// Adding some background | |
backgroundColor: Colors.blueGrey.shade200, | |
body: Center( | |
child: NeumorphicContainer(child: Text('Neumorphic')), | |
), | |
) | |
// ... |