79133619

Date: 2024-10-28 13:37:09
Score: 1
Natty:
Report link

Calling FocusScope.of(context).unfocus(); before showing the dialog didn't solve the problem for me. The previously focused TextField was still getting the focus after closing the dialog.

So, I created a global function in an utility class. I call this every time I want to close a dialog. The focus doesn't go back to any focusable widget after closing the dialog.

void closeDialog(BuildContext context) {
    Navigator.of(context).pop();
    FocusScope.of(context).unfocus();
}
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Ratul Hasan