1

我正在尝试从 firestore 检索数据作为下拉列表,得到了本教程并显示错误,请帮助,全新的颤振。

此函数的返回类型为“Row”,但不以 return 语句结束。尝试添加 return 语句,或将返回类型更改为“void”。

这是代码:

class _MyHomePageState extends State<MyHomePage> {
  var selectedCurrency, selectedType;
  final GlobalKey<FormState> _formKeyValue = new GlobalKey<FormState>();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          leading: IconButton(
              icon: Icon(
                Icons.edit,
                color: Colors.white,
              ),
              onPressed: () {}),
          title: Container(
            alignment: Alignment.center,
            child: Text("Account Details",
                style: TextStyle(
                  color: Colors.white,
                )),
          ),
          actions: <Widget>[
            IconButton(
              icon: Icon(
                Icons.edit,
                size: 20.0,
                color: Colors.white,
              ),
              onPressed: null,
            ),
          ],
        ),
        body: Form(
          key: _formKeyValue,
          autovalidate: true,
          child: new ListView(
            padding: const EdgeInsets.symmetric(horizontal: 15.0),
            children: <Widget>[
              SizedBox(height: 20.0),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Icon(
                    Icons.edit,
                    size: 25.0,
                    color: Color(0xff11b719),
                  ),
                  SizedBox(width: 50.0),
                ],
              ),
              SizedBox(height: 40.0),
              StreamBuilder<QuerySnapshot>(
                  stream: Firestore.instance.collection("currency").snapshots(),
                  builder: (context, snapshot) {
                  }),
              SizedBox(
                height: 150.0,
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: <Widget>[
                  RaisedButton(
                      color: Color(0xff11b719),
                      textColor: Colors.white,
                      child: Padding(
                          padding: EdgeInsets.all(10.0),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: <Widget>[
                              Text("Submit", style: TextStyle(fontSize: 24.0)),
                            ],
                          )),
                      onPressed: () {},
                      shape: new RoundedRectangleBorder(
                          borderRadius: new BorderRadius.circular(30.0))),
                ],
              ),
            ],
          ),
        ));
  }
}
4

1 回答 1

1

我自己对 Flutter 完全陌生,但似乎该类方法 确实有一个 return 语句。事实上,所有方法体都包含在该 return 语句中:buildMyHomePageState

  Widget build(BuildContext context) {
    return Scaffold(
        ...
  )}

该构建方法返回您的页面的完整描述,包括Row您在问题中提到的深度嵌套在结构中的内容:

return Scaffold(
        ...
        body: Form(
          ...
          child: new ListView(
            ...
            children: <Widget>[
              SizedBox(height: 20.0),
              Row(      <---------------- here it is
              ...

还是我错过了你的意思?

于 2019-12-01T10:10:37.877 回答