我在屏幕末尾有多个textFields和按钮,当我设置resizeToAvoidBottomPadding=false
时,它会阻塞整个屏幕,并且SingleChildScrollView
无法再滚动了,我只想处理按钮以使其位于键盘后面而不是上方
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomPadding: false,
body: body(context),
);
}
Widget body(BuildContext context) {
return Stack(
children: <Widget>[
SafeArea(
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overscroll) {
overscroll.disallowGlow();
return false;
},
child: Container(
height: double.infinity,
child: SingleChildScrollView(
padding: EdgeInsets.only(
left: 7 *
(SizeConfig.isMobilePortrait
? SizeConfig.widthMultiplier
: SizeConfig.heightMultiplier),
top: 20 *
(SizeConfig.isMobilePortrait
? SizeConfig.heightMultiplier
: SizeConfig.widthMultiplier),
),
physics: AlwaysScrollableScrollPhysics(),
child: Form(
autovalidate: false,
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(
vertical: 2 *
(SizeConfig.isMobilePortrait
? SizeConfig.widthMultiplier
: SizeConfig.heightMultiplier)),
child: registerText(context)),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
constraints: BoxConstraints(
maxWidth: 85 *
(SizeConfig.isMobilePortrait
? SizeConfig.widthMultiplier
: SizeConfig.heightMultiplier)),
child: firstNameField(context)),
Container(
constraints: BoxConstraints(
maxWidth: 85 *
(SizeConfig.isMobilePortrait
? SizeConfig.widthMultiplier
: SizeConfig.heightMultiplier)),
child: lastNameField(context)),
Container(
constraints: BoxConstraints(
maxWidth: 85 *
(SizeConfig.isMobilePortrait
? SizeConfig.widthMultiplier
: SizeConfig.heightMultiplier)),
child: emailField(context)),
Container(
constraints: BoxConstraints(
maxWidth: 85 *
(SizeConfig.isMobilePortrait
? SizeConfig.widthMultiplier
: SizeConfig.heightMultiplier)),
child: phoneNumberField(context)),
Container(
constraints: BoxConstraints(
maxWidth: 85 *
(SizeConfig.isMobilePortrait
? SizeConfig.widthMultiplier
: SizeConfig.heightMultiplier)),
child: passwordField(context)),
Container(
constraints: BoxConstraints(
maxWidth: 85 *
(SizeConfig.isMobilePortrait
? SizeConfig.widthMultiplier
: SizeConfig.heightMultiplier)),
child: confirmPasswordField(context)),
Container(
padding: EdgeInsets.only(
top: 2 *
(SizeConfig.isMobilePortrait
? SizeConfig.heightMultiplier
: SizeConfig.widthMultiplier)),
constraints: BoxConstraints(
minWidth: 80 *
(SizeConfig.isMobilePortrait
? SizeConfig.widthMultiplier
: SizeConfig.heightMultiplier)),
child: registerButton(context)),
// Container(child: registerButton(context))
],
),
],
),
)),
))),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
backToLogin(context),
],
)
],
);
}
最佳答案
resizeToAvoidBottomPadding=true
ID已弃用。
而是使用:resizeToAvoidBottomInset
我希望这有帮助
更新了
检查此链接,它应该有帮助:
This will fix the issue