searchBar static method

Widget searchBar({
  1. String? hintText,
  2. TextEditingController? controller,
  3. dynamic onChanged(
    1. String
    )?,
  4. VoidCallback? onClear,
  5. GlassType type = GlassType.frosted,
})

Glass search bar

Implementation

static Widget searchBar({
  String? hintText,
  TextEditingController? controller,
  Function(String)? onChanged,
  VoidCallback? onClear,
  GlassType type = GlassType.frosted,
}) {
  return GlassContainer(
    type: type,
    padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
    child: Row(
      children: [
        Icon(Icons.search, color: Colors.white70, size: 20.sp),
        SizedBox(width: 12.w),
        Expanded(
          child: TextField(
            controller: controller,
            onChanged: onChanged,
            style: AppTextThemes.bodyMedium(color: Colors.white),
            decoration: InputDecoration(
              hintText: hintText ?? 'Search...',
              hintStyle: AppTextThemes.bodyMedium(color: Colors.white60),
              border: InputBorder.none,
              isDense: true,
              contentPadding: EdgeInsets.zero,
            ),
          ),
        ),
        if (onClear != null) ...[
          SizedBox(width: 8.w),
          GestureDetector(
            onTap: onClear,
            child: Icon(Icons.clear, color: Colors.white70, size: 18.sp),
          ),
        ],
      ],
    ),
  );
}