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

Ontap stops responding after setState #3

Open
sidetraxaudio opened this issue Dec 3, 2021 · 3 comments
Open

Ontap stops responding after setState #3

sidetraxaudio opened this issue Dec 3, 2021 · 3 comments

Comments

@sidetraxaudio
Copy link

Great widget however I've experienced a problem:

I have an app-wide generic button utilising expand_tap_area. It works in all situations except this:

OnTap() calls SetState to change the size of some screen elements. It changes the icon for the button pressed and also changes the size of a container. Basically it's being used to change its own icon when pressed (on selected) and also expand a text box container to show more text.

The problem is that Ontap works the first time and does not work again. Swapping out for a gesture detector works fine.

` ShadedIconBtn(
icon: (isExpanded) ? FontAwesomeIcons.arrowCircleUp : FontAwesomeIcons.arrowCircleDown,

      onPressed: () {
        setState(() {
          isExpanded=!isExpanded;
          print('************************ BUTTON PRESSED');
        });
      },`

Print call also doesn't respond after it's pressed once. If I remove isExpanded bool that affects the rest of the screen elements and the screen doesn't change then the Print statement DOES work as expected.

As mentioned gesture detector works fine.

@malikwang
Copy link
Owner

Great widget however I've experienced a problem:

I have an app-wide generic button utilising expand_tap_area. It works in all situations except this:

OnTap() calls SetState to change the size of some screen elements. It changes the icon for the button pressed and also changes the size of a container. Basically it's being used to change its own icon when pressed (on selected) and also expand a text box container to show more text.

The problem is that Ontap works the first time and does not work again. Swapping out for a gesture detector works fine.

` ShadedIconBtn( icon: (isExpanded) ? FontAwesomeIcons.arrowCircleUp : FontAwesomeIcons.arrowCircleDown,

      onPressed: () {
        setState(() {
          isExpanded=!isExpanded;
          print('************************ BUTTON PRESSED');
        });
      },`

Print call also doesn't respond after it's pressed once. If I remove isExpanded bool that affects the rest of the screen elements and the screen doesn't change then the Print statement DOES work as expected.

As mentioned gesture detector works fine.

plz paste the key snippet of 'generic button' to debug this problem

@kameshWB
Copy link

kameshWB commented Dec 1, 2023

@sidetraxaudio use UniqueKey() to force rebuild the widget and that will update the new changes in your onTap method.

example
image

@malikwang Thank you so much, This is a very nice package. But this issues needs to be fixed, I was using this widget in many places and everywhere I was passing UniqueKey() to see my latest onTap changes.

@DaggeDaggmask
Copy link

@kameshWB @sidetraxaudio @malikwang you can copy the entire file in lib/src and modify the file to work with onTap.
Add this to the ExpandTapWidget under createRenderObject.

  @override
  void updateRenderObject(BuildContext context, covariant _ExpandTapRenderBox renderObject) {
    renderObject
      ..onTap = onTap
      ..tapPadding = tapPadding;
  }

onTap and tapPadding needs to be change to non-final variables in _ExpandTapRenderBox
Hope this helps.

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

4 participants