Home > front end >  What is the difference between onSubmitted and onEditingComplete in Flutter textField widget?
What is the difference between onSubmitted and onEditingComplete in Flutter textField widget?

Time:10-18

What is the difference between onSubmitted vs onEditingComplete in Flutter textField widgets?

I mean, onSubmitted already passes us the value the user has entered which we can use when submitting is done. Why need an onEditingComplete property?

I also came across this stackoverflow post

According to the top answer of this post, onEditingComplete is used to determine whether the keyboard should be hidden or kept after the user submits the data. If this is the case, why would flutter go leaps and bounds to have a property called onEditingComplete that ACCEPTS A FUNCTION? They could simply have a property like hideKeyboardAfterEditing which accepts either true or false.

(I might have understood the mention Stack Overflow post wrong here. But this is how my mind grasped it)

Can someone please help me understand this?

Thanks

CodePudding user response:

Both are technically the same but onEditingComplete will not lower the onscreen keyboard (example : chat apps) and onSubmitted will lower the onscreen keyboard and additionally onSubmitted will return the textfield value.

  • Related