Why my ui always rebuild when focus textfield?

When you click on TextField then build() method is called automatically by flutter. It seems your all widget is recreate again.

There is two responsibilities :

  1. Remove your MediaQuery. When keyboard popup, it will change the size of your screen. And it causing ui rebuild.
  2. Declare your GlobalKey<FormState> formKey as static and outside of your build() method. So your formKey just called once.

Just try it, good luck!

--

--

silsly
silsly

No responses yet