此函数的返回类型为“行”,但不以return语句结尾

时间:2019-12-01 09:57:14

标签: flutter google-cloud-firestore dropdownbutton

我正尝试从Firestore的下拉列表中检索数据,获得了本教程和错误提示,请提供帮助,这是全新的问题。

此函数的返回类型为“行”,但不以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))),
                ],
              ),
            ],
          ),
        ));
  }
}

1 个答案:

答案 0 :(得分:1)

我本人对Flutter还是陌生的,但看来build 方法 MyHomePageState确实有一个return语句。实际上,所有方法主体都包装在该return语句内:

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

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

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

还是我错过了你的意思?