我目前正在做我的第一个Flutter项目,在找东西方面遇到了相当多的麻烦。我已经有几天的问题之一是,当我在一个特定的视图中打开键盘时,我无法看到我的焦点TextFormField。
我最近发现Flutter实际上试图把焦点文本表单域放在我键盘的正上方,但是我的bottomSheet挡了道,见下图:第一节第一节第一节第一节第一次
并看到下面的代码为我的用户界面:
return Scaffold(
appBar: AppBar(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
'Capture moment',
),
Text(
'Tell me what happened.',
style: TextStyle(fontWeight: FontWeight.w400, fontSize: 18),
),
])),
body: CustomScrollView(slivers: [
SliverFillRemaining(
hasScrollBody: false,
child: Column(
children: [
Container(
margin: const EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Give your moment a name',
textAlign: TextAlign.left,
style: TextStyle(
fontWeight: FontWeight.w400, fontSize: 12),
),
SizedBox(height: 6),
SizedBox(
width: 340,
child: TextFormField(
onChanged: (value) => manager.setName(value),
initialValue: manager.name,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
vertical: 10.0, horizontal: 10.0),
hintText: 'F.e. meeting at work'),
)),
SizedBox(height: 12),
Text('Where did it happen?',
style: TextStyle(
fontWeight: FontWeight.w400, fontSize: 12)),
SizedBox(height: 6),
SizedBox(
width: 340,
child: TextFormField(
onChanged: (value) =>
manager.setLocation(value),
initialValue: manager.location,
decoration: InputDecoration(
hintText: 'F.e. Eindhoven',
contentPadding: EdgeInsets.symmetric(
vertical: 10.0, horizontal: 10.0),
),
)),
SizedBox(height: 12),
Text('Add an icon to your moment',
style: TextStyle(
fontWeight: FontWeight.w400, fontSize: 12)),
SizedBox(height: 6),
SizedBox(
width: 340,
child: TextFormField(
decoration: InputDecoration(
hintText: 'Search',
contentPadding: EdgeInsets.symmetric(
vertical: 10.0, horizontal: 10.0),
),
)),
SizedBox(height: 12),
Text('When did this happen?',
style: TextStyle(
fontWeight: FontWeight.w400, fontSize: 12)),
SizedBox(height: 6),
SizedBox(
width: 340,
child: Row(children: [
Text('Start'),
Spacer(),
DateTimeSelector(
initialValue: manager.startDate,
useTime: true,
onChanged: (value) =>
manager.setStartDate(value!),
)
])),
SizedBox(height: 12),
SizedBox(
width: 340,
child: Row(children: [
Text('End'),
Spacer(),
DateTimeSelector(
initialValue: manager.endDate,
useTime: true,
onChanged: (value) =>
manager.setEndDate(value!),
)
])),
],
)),
],
))
]),
bottomSheet: Container(
margin: const EdgeInsets.all(24.0),
child: SizedBox(
width: 340,
child: ElevatedButton(
onPressed: () => {
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) =>
const AddFeelingToMomentScreen()))),
},
child: const Text('Next'),
),
),
));
有人知道怎么修吗?先谢了!
1条答案
按热度按时间nkhmeac61#
您还可以在支架主体参数的开头使用ListView而不是Column