Current location - Recipe Complete Network - Complete cookbook of home-style dishes - In this paper, various intractable diseases encountered in using TextField in flutter are solved.
In this paper, various intractable diseases encountered in using TextField in flutter are solved.
You can use the SingleChildScrollView package layout.

Here you also need to know an attribute in scaffolding.

The explanation given by the official document is to deal with the problem of keyboard occlusion. The default value is true, and you need to set it to false if you don't want to top it.

ResizeToAvoidBottomPadding was used in the lower version of sdk, which needs to be set to false, and now it has been abandoned. However, many articles on the internet have not been corrected, and still use resizeToAvoidBottomPadding.

There are two situations.

One is to use the enter key of the system, such as the enter key that comes with the bottom navigation of Android.

The other is to use the navigation bar to customize the Enter key.

In the first case, you need to use WillPopScope in the page root layout to intercept the return processing in onWillPop.

The principle is to judge whether the input box has focus.

When there are fixed components at the bottom, such as the submit button, we want the button to be fixed at the top of the keyboard when it pops up, but the scroll view in the middle can scroll freely.

Stack packages can be reused outside SingleChildScrollView to locate floating buttons.

More? Pay attention to leave a distance at the bottom of the scroll component to prevent occlusion, and dynamically add the height of the bottomBar, because there will be a virtual button on the mobile phone above the iphoneX, and it will be occluded if the button height is not added.

Height acquisition method: mediaquery.of (context). Fill the bottom.

Use the Scaffold package in the showDialog layout, and don't forget to set the backgroundColor to transparent.

If the pop-up window is too high, you still need to fix the height, and then use SingleChildScrollView. In the pop-up window, it can also be intercepted when it is closed to judge whether the keyboard pops up. If it pops up, you must turn off the keyboard first.

Bind FoucusNode to all input boxes.

In the case of maxLines= 1, the input box does not support line feed, and the line feed button will become done.

Listen to onEditingComplete method

The root layout is wrapped in GestureDetector or InkWell, and the keyboard is put away when clicked.

Finally, remember to destroy it.