gpt4 book ai didi

flutter - 软键盘打开时小部件溢出

转载 作者:IT王子 更新时间:2023-10-29 07:22:58 28 4
gpt4 key购买 nike

我在 flutter 中使用带有选项卡的 TabBarView。我的标签栏 View 包含输入表单。现在当键盘打开时小部件溢出

我尝试使用 Listview 和 SingleChildScrollView 来避免这个问题,但它对我不起作用。使用 ListView 或 SingleChildScrollView 时,屏幕变为空白。

@override
Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
return new Scaffold(
resizeToAvoidBottomPadding: true,
body: SafeArea(
child: DefaultTabController(
length: 2,
child: Column(
children: <Widget>[
Expanded(
flex: 0,
child: TabBar(
tabs: [
Tab(text: 'Sign In'),
Tab(text: 'Sign Up'),
],
labelColor: Theme.of(context).primaryColor,
unselectedLabelColor: Colors.grey,
indicatorPadding: const EdgeInsets.symmetric(horizontal: 16.0),
labelPadding: const EdgeInsets.symmetric(vertical: 4.0),
),
),
Expanded(
flex: 1,
child: TabBarView(
children: [_buildSignInForm(), _buildSignupForm()]),
)
],
),
),
),
backgroundColor: Colors.white,
);
}

最佳答案

将您的 Column 包裹在 Container 小部件中,并通过以下方式设置高度以匹配屏幕高度:

`height: MediaQuery.of(context).size.height,`

关于flutter - 软键盘打开时小部件溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54655803/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com