Flutter Settings button disable

I. Description

In fact, if only to let the button does not respond to an event, there are many ways: You can use a variable to control your logic; onPressed can be set to null; AbsorbPointer can disable event ......

I was to give the button to set the scene disabledColor, a color when the button is enable, to disable time and is another color, but after setting disabledColor, how to set disable it, looked at all the properties of the button, nor enable related settings, ah, I went to this unreasonable it!

Second, the solution

We look at the instructions disableColor attributes:

your sister! So you enable the judge to determine whether the use onPressed is null! Sigh: vertical and horizontal load dozens of rivers and lakes, the first time I saw such a determination method, it is not routinely point, plus a property right?

Now know its implementation principle, you should also know how to disable the settings:

Just give onPressed set to null it.

 

Get!

Published 179 original articles · won praise 91 · views 330 000 +

Guess you like

Origin blog.csdn.net/haha223545/article/details/102916127