我正在使用步进器创建应用程序,但是在步进器中传递列表时出现错误
类似:未定义命名参数“ 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),
),
);
}
}
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),
),
);
}
}
[Stepper是
flutter/material package
中的类,因此请避免在应用程序中使用保留名称或使用的类名称。