Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isPressed #8

Open
aloisdeniel opened this issue Oct 15, 2024 · 1 comment
Open

Add isPressed #8

aloisdeniel opened this issue Oct 15, 2024 · 1 comment

Comments

@aloisdeniel
Copy link

aloisdeniel commented Oct 15, 2024

As far as I understand the logic, it is not possible to detect the isPressed state of the button.

I would typically use the onTapDown/Up/Cancel events from the gesture detector, but it would be easier if it would be directly provided by this package since it is very common (and would avoid using two GestureDetectors for every buttons)!

class _PressableState extends State<Pressable> {
  bool _isPressed = false;
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTapDown: (e) {
        setState(() {
          _isPressed = true;
        });
      },
      onTapUp: (e) {
        setState(() {
          _isPressed = false;
        });
      },
      onTapCancel: () {
        setState(() {
          _isPressed = false;
        });
      },
      child: FocusableControlBuilder(
         ....
      ),
    );
  }
}

Thanks

@esDotDev
Copy link
Contributor

Good call. Want to add a PR for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants