我正在使用Stepper创建App,但是在Stepper中传递列表时出现错误
类似的东西:未定义命名参数“ steps”
我的代码:
class Stepper extends StatefulWidget {
@override
_StateStepper createState() => _StateStepper();
}
class _StateStepper extends State<Stepper> {
List<Step> my_steps = [
new Step(title: Text("Step 1"), content: Text("Some Content")),
new Step(title: Text("Step 2"), content: Text("Some Content")),
new Step(title: Text("Step 3"), content: Text("Some Content")),
new Step(title: Text("Step 4"), content: Text("Some Content")),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: Text("Util App"),
),
body: Container(
child: Stepper(steps:my_steps),
),
);
}
}
答案 0 :(得分:2)
class MyStepper extends StatefulWidget {
@override
_StateStepper createState() => _StateStepper();
}
class _StateStepper extends State<Stepper> {
List<Step> my_steps = [
new Step(title: Text("Step 1"), content: Text("Some Content")),
new Step(title: Text("Step 2"), content: Text("Some Content")),
new Step(title: Text("Step 3"), content: Text("Some Content")),
new Step(title: Text("Step 4"), content: Text("Some Content")),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: Text("Util App"),
),
body: Container(
child: Stepper(steps:my_steps),
),
);
}
}
答案 1 :(得分:1)
Stepper是
flutter/material package
中的类,因此请避免在应用程序中使用保留名称或使用的类名称。