Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

flutter - 此函数的返回类型为“行”,但不以return语句结尾(This function has a return type of 'Row', but doesn't end with a return statement)

i am trying to retrieve data from firestore as dropdown list, got this tutorial and error show up, please help, totally new with flutter.

(我正在尝试从Firestore检索数据作为下拉列表,获得了本教程和错误提示,请帮助,这是全新的。)

This function has a return type of 'Row', but doesn't end with a return statement.

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

Try adding a return statement, or changing the return type to 'void'.

(尝试添加return语句,或将返回类型更改为'void'。)

here is the code :

(这是代码:)

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))),
                ],
              ),
            ],
          ),
        ));
  }
}
  ask by learnandro translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm totally new to Flutter myself, but it appears the method build of the MyHomePageState class does have a return statement.

(我本人对Flutter还是MyHomePageState ,但是MyHomePageState 方法 build确实具有return语句。)

In fact, all the method body is wrapped inside that return statement:

(实际上,所有方法主体都包装在该return语句内:)

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

That build method returns a complete description of your page, including the Row you mentioned in your question deeply nested in structure:

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

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

Or did I missed your point?

(还是我错过了你的观点?)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...