elevation method
void
elevation(
- double elevation, {
- double angle = 0.0,
- Color color = const Color(0x33000000),
- double opacity = 1.0,
inherited
Elevates the widget with a boxShadow.
angle
format depends on what is specified in the style widget`s constructor.
..elevation(30.0, color: Colors.grey, angle: 0.0)
Implementation
void elevation(double elevation,
{double angle = 0.0,
Color color = const Color(0x33000000),
double opacity = 1.0}) {
if (elevation == 0) return;
angle = angleToRadians(angle, angleFormat);
final double offsetX = sin(angle) * elevation;
final double offsetY = cos(angle) * elevation;
// custom curve defining the opacity
double calculatedOpacity = (0.5 - (sqrt(elevation) / 19)) * opacity;
if (calculatedOpacity < 0.0) calculatedOpacity = 0.0;
final Color colorWithOpacity = color.withOpacity(calculatedOpacity);
_styleModel.boxShadow = [
BoxShadow(
color: colorWithOpacity,
blurRadius: elevation,
spreadRadius: 0.0,
offset: Offset(offsetX, offsetY))
];
}