问题
When focussing on the TextFormField, the keyboard hides over the TextFormField. I am using SingleScrollview with the Column widget. Below I attached a screenshot with coding. Please guide me in fixing this issue.
Scaffold(
resizeToAvoidBottomInset: false,
resizeToAvoidBottomPadding: false,
key: _scaffoldKey,
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: new Column(
children: <Widget>[
_tabText(),
isSignin ? _loginContainer() : _signUpContainer(),
],
),),),);
回答1:
You have to remove these properties of the Scaffold
:
resizeToAvoidBottomInset: false,
resizeToAvoidBottomPadding: false,
If you remove them, resizeToAvoidBottomInset
will be true
by default.
resizeToAvoidBottomInset property:
...if there is an onscreen keyboard displayed above the scaffold, the body can be resized to avoid overlapping the keyboard, which prevents widgets inside the body from being obscured by the keyboard.
回答2:
Try SingleChildScrollView() widget after scaffold() widget. wrap all widgets with SingleChildScrollView() widget after Scaffold() widget.
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Form(
key: formKey,
child: Column(
children: <Widget>[
Container(
child: Stack(
children: <Widget>[
Container(
回答3:
//Add this line "resizeToAvoidBottomInset: true," to your Scaffold and put your main container in ScrollView.
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: true,
key: _scaffoldKey,
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Container()
),
);
}
来源:https://stackoverflow.com/questions/59694058/textformfield-hidden-by-keyboard-flutter