glassEffect method

Color glassEffect({
  1. double opacity = 0.5,
  2. double brightnessFactor = 0.2,
})

Creates a glass-like effect by combining transparency and brightness adjustment. The opacity controls the transparency and brightnessFactor adjusts the brightness.

Implementation

Color glassEffect({double opacity = 0.5, double brightnessFactor = 0.2}) {
  assert(opacity >= 0.0 && opacity <= 1.0, "Opacity must be between 0.0 and 1.0");
  assert(brightnessFactor >= 0.0 && brightnessFactor <= 1.0, "Brightness must be between 0.0 and 1.0");
  final adjustedBrightness = Color.lerp(this, Colors.white, brightnessFactor)!;
  return adjustedBrightness.withOpacity(opacity);
}