Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 无法将文本字段添加到脚手架_Flutter_Dart - Fatal编程技术网

Flutter 无法将文本字段添加到脚手架

Flutter 无法将文本字段添加到脚手架,flutter,dart,Flutter,Dart,我是个新手(大概一个星期)。我正在尝试在列表视图上方添加搜索字段。听起来很简单。然而,我得到了一个对我来说毫无意义的错误(即使在大量的谷歌搜索和阅读文档之后)。我理解这个错误,只是不理解为什么我会得到它 return Scaffold( body : Padding( padding: EdgeInsets.all(3.0), child: TextField( controlle

我是个新手(大概一个星期)。我正在尝试在列表视图上方添加搜索字段。听起来很简单。然而,我得到了一个对我来说毫无意义的错误(即使在大量的谷歌搜索和阅读文档之后)。我理解这个错误,只是不理解为什么我会得到它

return Scaffold(
        body :
        Padding(
          padding: EdgeInsets.all(3.0),
          child:
          TextField(
            controller: searchController,
            decoration: InputDecoration(
                icon: Icon(Icons.search),
                hintText: "search text",
                border: OutlineInputBorder()
            ), //decoration
          ), //textfield
        ), // padding
        ListView.builder(
          itemCount : contactsModel.entityList.length,
          itemBuilder : (BuildContext inBuildContext, int inIndex) {
            Contact contact = contactsModel.entityList[inIndex];
            return Column(
              children : [
                Slidable(
                  delegate : SlidableDrawerDelegate(),
                  actionExtentRatio : .25,
                  child : ListTile(
                    title : Text("${contact.password}"),
                    subtitle : contact.pwordHint == null ? null : Text("${contact.pwordHint} - ${contact.notes}"),
                    // Edit existing contact.
                    onTap : () async {
                      contactsModel.entityBeingEdited = await ContactsDBWorker.db.get(contact.id);
                      contactsModel.setStackIndex(1);
                    }
                  ),
                  secondaryActions : [
                    IconSlideAction(
                      caption : "Delete",
                      color : Colors.red,
                      icon : Icons.delete,
                      onTap : () => _deleteContact(inContext, contact)
                    )
                  ]
                ),
                Divider()
              ]
            ); /* End Column. */
          } /* End itemBuilder. */
        ), /* End ListView.builder. */
          floatingActionButton : FloatingActionButton(
            child : Icon(Icons.add, color : Colors.white),
            onPressed : () async {
              contactsModel.entityBeingEdited = Contact();
              contactsModel.setStackIndex(1);
            }
          ),
      ); /* End Scaffold. */
我得到的错误是:

error: Too many positional arguments: 0 expected, but 1 found. (extra_positional_arguments_could_be_named at SCAFFOLD LINE
error: Positional arguments must occur before named arguments. (positional_after_named_argument at LISTVIEW.BUILDER LINE
如果我删除“BODY:”之后的PADDING()部分,则没有错误


我不知道为什么Listview与Padding不同。我想我遗漏了一个或多个可以让答案变得显而易见的基本概念。非常感谢您的指导。

这是因为您正在使用

Scaffold(
  body: Widget1(),
        Widget2(),
  ...
)
这里的
Widget1
是您的
Padding
Widget2
ListView.builder

这不是正确的方法。您可以将
Widget1
Widget2
包装在
堆栈
中,以适合您的需要为准,如下所示:

Scaffold(
  body: Column(
    children: <Widget>[
      Widget1(),
      Widget2(),
    ],
  ),
)
脚手架(
正文:专栏(
儿童:[
Widget1(),
Widget2(),
],
),
)

既然有人向我指出了这一点,那就非常有意义了。熟能生巧。谢谢。我是否必须指定灵活的位置,因为我得到一个“垂直视口被赋予无限高度”。运行时出错?或者是否有其他方法来指定列高度?如果我这样做了,在哪里?将你的
列表视图
包装在
展开的
中。我将ListView.builder包装为:“展开的(“and”),”没有区别。你能用代码发布另一个问题吗,我会很快回答。