Textformfield unfocus when onTapOutside but not onScroll

  Kiến thức lập trình

In a TextFormField I’m trying to unfocus with onTapOutside instead of using a GestureDetector, to unfocus when I tap outside the TextFormField.

onTapOutside: (pointer) {
  if (FocusScope.of(context).focusedChild != null) {
    FocusScope.of(context).focusedChild!.unfocus();
  }
},

The problem is that since we start scrolling in the page it also unfocus the field selected.
Is there a way currently to patch this problem from onTapOutside ?
Is it possible to use onTapOutside without losing the focus when scrolling ?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT