fluttermaterialbutton

Flutter- how to disable a Button untill the requireed fields are filled


I want to disable a button untill all the required fields are filled. I found similar questions here but all answers are based on making the onPressed property to null. But it does not disable the tap effect.

enter image description here

enter image description here

I want something like this. On disabled mode, clicking on the button won't even cause a Tap effect. Can someone help with a solution?


Solution

  • For a limited number of widgets, you can wrap them in a widget IgnorePointer: when its ignoring property is set to true, the sub-widget (actually, the entire subtree) is not clickable.

    IgnorePointer(
        ignoring: true, // or false
        child: CustomButton(
            onPressed: _login,
            child: Text("Login"),
            ),
    )