How do I disable a Button in Flutter?

后端 未结 8 2158
不思量自难忘°
不思量自难忘° 2020-12-04 17:19

I\'m just starting to get the hang of Flutter, but I\'m having trouble figuring out how to set the enabled state of a button.

From the docs, it says to set onP

8条回答
  •  悲&欢浪女
    2020-12-04 17:38

    This is the easiest way in my opinion:

    RaisedButton(
      child: Text("PRESS BUTTON"),
      onPressed: booleanCondition
        ? () => myTapCallback()
        : null
    )
    

提交回复
热议问题