InputOptions.glassmorphic constructor

InputOptions.glassmorphic({
  1. List<Color>? colors,
  2. double borderRadius = 24.0,
  3. double blurStrength = 10.0,
  4. String? hintText,
  5. Color? textColor,
  6. Color? hintColor,
  7. bool useOuterContainer = true,
  8. TextEditingController? textController,
  9. bool sendOnEnter = true,
})

Creates a glassmorphic input field with a frosted glass effect.

Implementation

factory InputOptions.glassmorphic({
  List<Color>? colors,
  double borderRadius = 24.0,
  double blurStrength = 10.0,
  String? hintText,
  Color? textColor,
  Color? hintColor,
  bool useOuterContainer = true,
  TextEditingController? textController,
  bool sendOnEnter = true,
}) {
  final effectiveColors = colors ??
      [
        Colors.white.withOpacityCompat(0.3),
        Colors.white.withOpacityCompat(0.2),
      ];

  return InputOptions(
    textController: textController,
    useOuterContainer: useOuterContainer,
    sendOnEnter: sendOnEnter,
    blurStrength: blurStrength,
    textStyle: textColor != null ? TextStyle(color: textColor) : null,
    containerBackgroundColor: Colors.transparent,
    containerDecoration: BoxDecoration(
      gradient: LinearGradient(
        colors: effectiveColors,
        begin: Alignment.topLeft,
        end: Alignment.bottomRight,
      ),
      borderRadius: BorderRadius.circular(borderRadius),
      border: Border.all(
        color: Colors.white.withOpacityCompat(0.2),
        width: 1.5,
      ),
    ),
    decoration: InputDecoration(
      hintText: hintText,
      hintStyle: hintColor != null ? TextStyle(color: hintColor) : null,
      border: InputBorder.none,
      contentPadding: const EdgeInsets.symmetric(
        horizontal: 16.0,
        vertical: 10.0,
      ),
    ),
  );
}