ListView上的Flutter Stepper

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

我有疑问,我在listView中有一个Stepper但它甚至不能被骂,我试了三天,但是没有结果,为什么会发生这种情况以及如何解决它?

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

这是我的代码,

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
          )
        ],
      ),
    ),   ], ),

谢谢你们所有答案,最好的关注。

dart flutter flutter-layout
1个回答
1
投票

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

如果你想把它放在ListView中,你可以简单地在physics: ClampingScrollPhysics()中设置Stepper

© www.soinside.com 2019 - 2024. All rights reserved.