编辑文本字段时键盘隐藏文本字段(颤动)
Keyboard hide textfield when editing textfield( flutter)
在编辑我的文本字段时,键盘隐藏了半个屏幕。我想让屏幕用键盘向上推,这样我就可以看到所有的领域。我该怎么做?
这是我的小部件表单,我已经尝试过 SingleScrollView,但问题是我的视图全变白了
class SignUpFormState extends State<_SignUpForm> {
final _signUpFormKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Consumer<LoginModel>(
builder: (context, loginModel, child) => Expanded(
child: Padding(
padding: EdgeInsets.only(left: 16.0, right: 16.0),
child: Card(
child: Form(
key: _signUpFormKey,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
children: <Widget>[
Container( height: 16.0,),
Text(),
Spacer(flex: 3, ),
Padding(),
Padding(),
Padding(),
Padding(),
Spacer( flex: 4,),
Row(),
],
),
)),
),
),
));
}
}
使用Scaffold
小部件作为屏幕的根。问题就解决了。
例如:
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView( // or Column
// contents
)
);
}
使用 SingleChildView 喜欢这个。
class SomeWidgetState extends State<SomeWidget> {
@override
Widget build(BuildContext context) {
//If you use Scaffold in parent widget, use Container instead of Scaffold.
return Scaffold(
body: SingleChildScrollView(
child: Column([Your Login Form Widget])
)
}
}
使用Scaffold
作为根并添加
resizeToAvoidBottomPadding: false,
就在 scaffold
括号结束之前。一切顺利。
示例:
return Scaffold(
body: Column(
.....
),
resizeToAvoidBottomPadding: false, //this line here
);
在编辑我的文本字段时,键盘隐藏了半个屏幕。我想让屏幕用键盘向上推,这样我就可以看到所有的领域。我该怎么做?
这是我的小部件表单,我已经尝试过 SingleScrollView,但问题是我的视图全变白了
class SignUpFormState extends State<_SignUpForm> {
final _signUpFormKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Consumer<LoginModel>(
builder: (context, loginModel, child) => Expanded(
child: Padding(
padding: EdgeInsets.only(left: 16.0, right: 16.0),
child: Card(
child: Form(
key: _signUpFormKey,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
children: <Widget>[
Container( height: 16.0,),
Text(),
Spacer(flex: 3, ),
Padding(),
Padding(),
Padding(),
Padding(),
Spacer( flex: 4,),
Row(),
],
),
)),
),
),
));
}
}
使用Scaffold
小部件作为屏幕的根。问题就解决了。
例如:
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView( // or Column
// contents
)
);
}
使用 SingleChildView 喜欢这个。
class SomeWidgetState extends State<SomeWidget> {
@override
Widget build(BuildContext context) {
//If you use Scaffold in parent widget, use Container instead of Scaffold.
return Scaffold(
body: SingleChildScrollView(
child: Column([Your Login Form Widget])
)
}
}
使用Scaffold
作为根并添加
resizeToAvoidBottomPadding: false,
就在 scaffold
括号结束之前。一切顺利。
示例:
return Scaffold(
body: Column(
.....
),
resizeToAvoidBottomPadding: false, //this line here
);