1

i have a flutter app using SystemUiMode.immersive, but when i use my keyboard and discards it, the navbar (and status bar) stays on the app.

I have code that removes them if you touch the screen, but sometimes they hide things and users get confused.

any solution?

1 Answer 1

0

You can use FocusNode to listen to the changes that you need in keyboard focus.

FocusNode _focusNode = FocusNode();

@override
void initState() {
  super.initState();
  _focusNode.addListener(() {
    if (!_focusNode.hasFocus) {
      SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
    }
  });
}

@override
void dispose() {
  _focusNode.dispose();
  super.dispose();
}

Widget build(BuildContext context) {
  return Scaffold(
    body: GestureDetector(
      onTap: () {
        FocusScope.of(context).requestFocus(FocusNode());
      },
      child: // Your child...
    ),
  );
}

This means that when your keyboard is dismissed, you can hide the system ui programmitically.

Happy coding...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.