我正在尝试使用一个容器来显示TextField,但是该容器不喜欢我的操作顺序。这是我的代码:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("New Grocery List"),
),
drawer: AppDrawer(),
Container(
child: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Default TextField',
),
),
],
),
)
);
}我发现容器代码在另一个可能起作用的线程中,所以我认为它是由于其他原因而发生的。
最佳答案
问题是您缺少脚手架的 body 。尝试将body:
放在Contaiter之前。
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("New Grocery List"),
),
drawer: AppDrawer(),
body: Container( //put body in this line
child: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Default TextField',
),
),
],
),
)
);
}
关于flutter - “Positional arguments must occur before named arguments. Try moving all of the positional arguments before the named arguments”错误抖动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62643792/