glassContainer method

Widget glassContainer({
  1. double? width,
  2. double? height,
  3. double? borderRadius,
  4. double? blurRadius,
  5. Widget? child,
  6. Color? glassTintColor,
  7. int? densityMultiplier,
  8. bool enabled = true,
})

Implementation

Widget glassContainer(
    {double? width,
    double? height,
    double? borderRadius,
    double? blurRadius,
    Widget? child,
    Color? glassTintColor,
    int? densityMultiplier,
    bool enabled = true}) {
  Color color = glassTintColor ?? Colors.white;
  if (!enabled) {
    return child ?? SizedBox.shrink();
  }
  return Container(
    decoration: BoxDecoration(
      color: Colors.transparent,
      borderRadius:
          BorderRadius.circular(borderRadius ?? DUI.spacing.borderRadius),
    ),
    width: width,
    height: height,
    clipBehavior: Clip.antiAlias,
    child: BackdropFilter(
      filter: ImageFilter.blur(
        sigmaX: blurRadius ?? 8.0,
        sigmaY: blurRadius ?? 8.0,
      ),
      child: ClipRRect(
          borderRadius:
              BorderRadius.circular(borderRadius ?? DUI.spacing.borderRadius),
          child: Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(
                  borderRadius ?? DUI.spacing.borderRadius),
              border: Border.all(color: color.withOpacity(0.10)),
              gradient: LinearGradient(
                  begin: Alignment.topLeft,
                  end: Alignment.bottomRight,
                  colors: [
                    color.withOpacity(0.10 * (densityMultiplier ?? 1)),
                    color.withOpacity(0.05 * (densityMultiplier ?? 1)),
                  ]),
            ),
            child: child,
          )),
    ),
  );
}