Home > other >  Flutter - 'onSurface' is deprecated and shouldn't be used. Use disabledForegroundColo
Flutter - 'onSurface' is deprecated and shouldn't be used. Use disabledForegroundColo

Time:09-02

In flutter version 3.3.0 ElevatedButton onSurface is deprecated i am confused which property should i use instead onSurface. should i use disabledForegroundColor or disabledBackgroundColor or Both?

enter image description here

CodePudding user response:

If you need to change both text and button color for disabled state, you should use both disabledForegroundColor and disabledBackgroundColor.

But

using normally only the disabledBackgroundColor should be enough for the button.

CodePudding user response:

Use foregroundColor and disabledForegroundColor instead of onSurface.

style: ElevatedButton.styleFrom(
  foregroundColor:Colors.red,
  disabledForegroundColor:Colors.green,
  • Related