我如何在Flutter中通过步进器传递列表

问题描述 投票:0回答:2

我正在使用步进器创建应用程序,但是在步进器中传递列表时出现错误

Somrthing Like:未定义命名参数“ 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),
      ),
    );
  }
}
flutter flutter-layout
2个回答
0
投票
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), ), ); } }

0
投票
[Stepperflutter/material package中的类,因此请避免在应用程序中使用保留名称或使用的类名称。
© www.soinside.com 2019 - 2024. All rights reserved.