How do I disable a Button in Flutter?

后端 未结 8 2159
不思量自难忘°
不思量自难忘° 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:36

    For a specific and limited number of widgets, wrapping them in a widget IgnorePointer does exactly this: when its ignoring property is set to true, the sub-widget (actually, the entire subtree) is not clickable.

    IgnorePointer(
        ignoring: true, // or false
        child: RaisedButton(
            onPressed: _logInWithFacebook,
            child: Text("Facebook sign-in"),
            ),
    ),
    

    Otherwise, if you intend to disable an entire subtree, look into AbsorbPointer().

提交回复
热议问题