flutter代码中有一个bottomsheet——bottomsheet包含一个TextField,当点击TextField时,键盘覆盖了TextField。
下面是底页的代码
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext buildContext) {
return SizedBox(
child: Wrap(
direction: Axis.vertical,
crossAxisAlignment:
WrapCrossAlignment.center,
children: [
//Email EIT
WidgetInputText(
widgetShade:
Theme.of(context).brightness !=
Brightness.dark
? Colors.purple
: Colors.pink,
inputHint: "Your Email",
inputIcon: Icons.person,
),
Container(
padding: const EdgeInsets.only(
top: 16, bottom: 16),
width:
MediaQuery.of(context).size.width *
.8,
child: Row(
children: [
RoundedButton(
btnText: "Raise Request",
btnColorShade: Theme.of(context)
.brightness !=
Brightness.dark
? Colors.purple
: Colors.pink,
),
const SizedBox(
width: 16,
),
RoundedButton(
clickAction: () {
print("CALLED");
Navigator.pop(context);
},
btnText: "Cancel",
btnColorShade: Theme.of(context)
.brightness !=
Brightness.dark
? Colors.pink
: Colors.purple,
),
],
),
),
],
),
);
})
WidgetInputText 代码
class WidgetInputText extends StatelessWidget {
MaterialColor widgetShade;
String inputHint;
IconData inputIcon;
WidgetInputText(
{super.key,
required this.widgetShade,
required this.inputHint,
required this.inputIcon});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
width: MediaQuery.of(context).size.width * .8,
decoration: BoxDecoration(
color: widgetShade.shade50, borderRadius: BorderRadius.circular(30)),
child: TextField(
style: const TextStyle(color: Colors.black),
decoration: InputDecoration(
labelStyle: TextStyle(color: widgetShade),
labelText: inputHint,
border: InputBorder.none,
icon: Icon(
inputIcon,
color: widgetShade.shade500,
))),
);
}
}
以下是问题屏幕截图
我已经尝试过将 BottomSheet 包装到 SingleChildScrollView 中,但这不起作用。
我也尝试过使用应用程序/屏幕级支架 resizeToAvoidBottomInset:假, resizeToAvoidBottomPadding:假,
以上事情对我不起作用
在
AndroidManifest.xml
中,将 windowSoftInputMode
的 activity
更改为 adjustPan
。
<application ... >
<activity
android:windowSoftInputMode="adjustPan" ... >
...
</activity>
...
</application>
更多信息在这里:https://developer.android.com/develop/ui/views/touch-and-input/keyboard-input/visibility