【发布时间】:2021-02-06 02:01:54
【问题描述】:
我有一个带有三个下拉按钮的表单,这些按钮是在类的顶部声明的,
String _currentItemSelected1 = 'low';
String _currentItemSelected2 = 'low';
String _currentItemSelected3 = 'low';
然后我有 RisedButton 和这个 body 的 onPressed 属性:
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SuggestionResult(
_currentItemSelected1,
_currentItemSelected2,
_currentItemSelected3,
),
),
);
在 SuggestionResult 类中,我重写了构造函数,如下所示:
final String temp;
final String hum;
final String light;
SuggestionResult({this.temp, this.hum, this.light});
现在,问题是当我调用 SuggestionResult 类时,它说:“位置参数太多:预期为 0,但找到了 3。 尝试删除额外的位置参数,或指定命名参数的名称。”
【问题讨论】:
-
你需要了解 dart 中位置参数和命名参数的区别。看看this question。
标签: flutter dart parameters navigation