nank1ro/flutter-shadcn-ui

Button Issues

Closed this issue · 1 comments

I plan on going through each component and comparing it the materials implementation to see if anything is missing.
If you rather me do this elsewhere please let me know, I will modify this issue as I find more things.

  • Eplicitly setting onPressed to null doesn't give a disabled button look. This is a really neat part from Materials button & would be nice to have here.
  • Long press is not implemented
  • No way to listen to MaterialStates. I hate the states controller as much as the next guy, but listening to hover could be helpful.

Thanks for this @dickermoshe 🙏

1: I don't find it neat. Let me explain why IMHO enabled is better.

onPressed: enabled ? func : null,

In the example above you have to use a ternary operator and it doesn't become very readable when the function is large.

enabled: enabled,
onPressed: func,

While in this example, you don't have to change the onPressed, but just change the enabled state.
This is the same behaviour you have on HTML fields, and it's way more readable.
Another reason is when I have a callback, something like onChanged<T>, when you pass null to disable it, Dart cannot automatically find what is T, which would become Object?, this happens in the select component for example.
I just want to be consistent and I think this is the best approach. Let me know what you think

2 and 3: Will implement them