rydmike / flex_color_scheme

A Flutter package to make and use beautiful color scheme based themes.
Other
947 stars 105 forks source link

how to use this disable button theme? #184

Closed yunchiri closed 1 year ago

yunchiri commented 1 year ago
image

how to use disbale "Elevated Button"

thanks library

rydmike commented 1 year ago

Hi @yunchiri, thank you for you question.

Can you explain a bit more about what you mean? Below a few guesses and their answers, but since I am not sure I understand the question correctly, the answer may not be what you are looking for.

Q1: How do I get this style of ElevatedButton in disabled mode in? A1: Since you have it configured in the Playground, if you copy the theme from the playground generated code config, and use it in your app's MaterialApp.theme this is the style you will then get when the ElevatedButton is in its disabled state.

Q2: How do I recreate the shown style in the image? A2: A bit hard to say exactly from the screen shot what configs have been made in the Playground. I would need a copy-paste of the generated code config, to tell you the exact steps are in the Themes Playground to get the shown button style.

Q3: How do I disable a button, in this case the ElevatedButton in Flutter? A3: Not really a FlexColorScheme or Themes Playground question, but the buttons get their disabled style when their onPressed callback is set to null. This is just how Flutter Material buttons work.

So to disable a button conditionally you can e.g. use a ternary operator:

   :
   ElevatedButton(
     onPressed: buttonIsDisabled ? null : () { ...enabled press actions },
     child: Text('Elevated button'),
   ),
   :

Hope this helps, this does not seem to be an issue though, so I'm closing the issue and moving the question to the Discussions section as a Q&A. Feel free to continue the discussion there and provide more info if the above answer did not help.