扑朔迷离。这是我的代码。有人可以告诉我我错了吗? 另外,我不希望在键盘出现时隐藏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()
],
),
)
);
答案 0 :(得分:0)
我不想在键盘出现时隐藏TextField。在那儿 除了使用KeyboardAvoider以外,还有其他方法吗?
将脚手架上的resizeToAvoidBottomInsets
属性设置为true
标题:
展开的窗口小部件必须放在Flex小部件中
您正在将Flex
小部件放在Widget
不扩展的Flex
内(例如Column
和Row
扩展Flex
,因此您应该删除Expanded
或将其包装在扩展Widget
Flex
中