FocusNode should lose focus when clicking outside the widget

Viewed 39

does anyone know how to make a focus node loose focus when clicking outside the focus node ? Basically, I got something like this:

      InkWell(
        focusNode: focusNode,
        child: ...,
        onTap: () {
          ...
        },
      ),

But the focusNode doesn't lose his focus when I'm clicking outside the InkWell widget.

I have tried to use the FocusTrap widget, which seems to do exactly that. But I can't get a focusScopeNode from my focusNode, all I get is null (I don't really understand how focusScopeNode works)

Note that I can't do something hacky like

GestureDetector(
  onTap: () {
    Focus.of(context).unfocus();
  },
  child: Scaffold(
    // ...
  ),
);

Because I'm in a package context

Does anyone know how to do this ?

0 Answers
Related