public static void UpdateClearButtonVisibility(this AppCompatEditText editText, IEntry entry, Func <Drawable?>?getClearButtonDrawable)
        {
            // Places clear button drawable at the end or start of the EditText based on FlowDirection.
            void ShowClearButton()
            {
                var drawable = getClearButtonDrawable?.Invoke();

                if (entry.FlowDirection == FlowDirection.RightToLeft)
                {
                    editText.SetCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
                }
                else
                {
                    editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
                }
            }

            // Hides clear button drawable from the control.
            void HideClearButton()
            {
                editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
            }

            bool isFocused = editText.IsFocused;
            bool hasText   = entry.Text?.Length > 0;

            bool shouldDisplayClearButton = entry.ClearButtonVisibility == ClearButtonVisibility.WhileEditing &&
                                            hasText &&
                                            isFocused;

            if (shouldDisplayClearButton)
            {
                ShowClearButton();
            }
            else
            {
                HideClearButton();
            }
        }