flutter - 展开的小部件必须放在 Flex 小部件内
问题描述
新来的扑腾。这是我的代码。有人能告诉我哪里错了吗?另外,我不希望在键盘出现时隐藏 TextField。除了使用 KeyboardAvoider 之外,还有其他方法可以做到这一点吗?
return Scaffold(
resizetoavoidbottomInsets: true,
body: SafeArea(
child: Stack(
children: <Widget>[
Container(height: MediaQuery.of(context).size.height),
Image.asset('images/otp.jpeg'),
Positioned(
top: MediaQuery.of(context).size.height * 0.3,
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.7,
child: ListView(
children: <Widget>[
Text('Welcome),
Spacer(
flex: 1,
),
Container(
width: MediaQuery.of(context).size.width * 0.8,
height: MediaQuery.of(context).size.height * 0.07,
child: Form(
key: _formKey,
child: TextFormField(),
),
),
Spacer()
],
),
)
);
解决方案
当键盘出现时,我不希望 TextField 被隐藏。除了使用 KeyboardAvoider 之外,还有其他方法可以做到这一点吗?
resizeToAvoidBottomInsets
将脚手架上的属性设置为 true
至于标题:
展开的小部件必须放在 Flex 小部件内
您将一个Flex
小部件放在Widget
不扩展的 a 中Flex
(例如Column
和Row
extend Flex
,因此您应该删除Expanded
或将其包装在Widget
扩展的 a 中Flex
推荐阅读
- python - 为什么每个请求中的 ID 都不同?
- c++ - SFINAE 没有正确判断方法是否存在
- python - 如何在 Python 的数据框中创建两列的交叉表并在输出中生成总行和列?
- c# - Pop Async 删除内容页面资源标题
- python - 裁剪和保存 Tensorflow 对象检测 API 中的检测
- android - 如何在android studio中仅删除xlarge的布局?
- azure - Azure AD - 企业应用程序中缺少“Office 365 管理 API”
- certificate - https on amason EC2 与 OVH CDN
- flutter - 同意消息未显示
- python - 在numpy中加倍列表