【问题标题】:Flutter Stepper on ListViewListView 上的颤振步进器
【发布时间】:2019-03-22 09:48:16
【问题描述】:

我有问题, 我在listView中有一个Stepper却连scolled都打不开,试了三天,还是没有结果,为什么会出现这种情况,如何解决?

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

这是我的代码,

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】:

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

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

【讨论】:

  • 感谢您的回答@Niklas,问题是我希望我的滚动条可以运行并且步进器可以点击,您还有其他建议吗?还是我必须用不同的小部件替换列表?
  • 尝试在步进器中设置physics: ClampingScrollPhysics()
  • 知道了,我找到了答案,答案是因为我的flutter没有更新。所以physics: ClampingScrollPhysics () 函数不存在。更新后,代码运行良好,感谢@Niklas @Hemanth Raj,最好的尊重,
猜你喜欢
  • 2019-04-19
  • 1970-01-01
  • 2021-08-29
  • 1970-01-01
  • 2021-10-22
  • 1970-01-01
  • 2021-02-13
  • 2020-12-09
  • 2020-12-17
相关资源
最近更新 更多