ListView上的Flutter Stepper

时间:2019-03-22 09:48:16

标签: dart flutter flutter-layout

我有问题, 我在listView中有一个步进器,但它甚至无法运行,我尝试了三天,但没有结果,为什么会发生这种情况以及如何解决呢?

有人可以帮我解决这个问题吗?

这是我的代码,

new ListView(   padding: EdgeInsets.fromLTRB(5.0, 0.0, 5.0, 3.0),   children: <Widget>[
    new ListTile(
      title: new Text(
        "Day 1",
        style: new TextStyle(fontSize: 20.0, color: Colors.lightGreen, fontWeight: FontWeight.bold,fontFamily: 'GoogleSans'),
      ),
      subtitle: new Stepper(
        currentStep: this._currentStep1,
        onStepTapped: (step){
          setState(() {
            this._currentStep1 = step;
          });
        },
        onStepContinue: (){
          setState(() {
            if(this._currentStep1 < 4){
              this._currentStep1 += 1;
            } else {
              //logika jika komplit
            }
          });
        },
        onStepCancel: (){
          setState(() {
            if(this._currentStep1 > 0){
              this._currentStep1 -= 1;
            } else {
              this._currentStep1 = 0;
            }
          });
        },
        steps: [
          Step(
              title: new Text("arrived in bali.",style: new TextStyle(fontSize: 16.0, color: Colors.black87, fontWeight: FontWeight.bold,fontFamily: 'GoogleSans')),
              content: new Text("to register please show your QR code on the attendance menu. when it arrived at the venue to the admin.",style: new TextStyle(fontSize: 14.0, color: Colors.grey,fontFamily: 'GoogleSans')),
              isActive: _currentStep1 >= 0
          ),
          Step(
              title: new Text("arrived in hotel bali.",style: new TextStyle(fontSize: 16.0, color: Colors.black87, fontWeight: FontWeight.bold,fontFamily: 'GoogleSans')),
              content:  new Text("to book a room when it arrives at the hotel, show your QR code to the hotel admin to scan it.",style: new TextStyle(fontSize: 14.0, color: Colors.grey,fontFamily: 'GoogleSans')),
              isActive: _currentStep1 >= 2
          ),
          Step(
              title: new Text("Step 3"),
              content: new TextField(),
              isActive: _currentStep1 >= 3
          ),
          Step(
              title: new Text("Step 4"),
              content: new TextField(),
              isActive: _currentStep1 >= 4
          ),
          Step(
              title: new Text("Step 5 "),
              content: new TextField(),
              isActive: _currentStep1 >= 5
          )
        ],
      ),
    ),   ], ),

感谢您的所有回答, 最好的问候。

1 个答案:

答案 0 :(得分:1)

Stepper本身已经是可滚动的小部件。

如果要将其放置在ListView中,只需在physics: ClampingScrollPhysics()内设置Stepper