how to disable a button after click first time?
Asked
Active
Viewed 1,329 times
1 Answers
1
To disable a button, you have to set its onPressed
method to null. You can use a ternary operator for this. So what I'm doing here is basically, giving a function to onPressed
method conditionally. If _isButtonDisabled is false, onPressed method gets null
which makes it disabled, otherwise it gets the function.
onPressed: _isButtonDisabled ? null : _functionThatDoesSomething,
You can put your _isButtonDisabled variable to your state, and set it to false in your _functionThatDoesSomething
body. Probably at the end of the function.

mirkancal
- 4,762
- 7
- 37
- 75