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

Button state bug🐛 #230

Closed
AbrasiveBoar902 opened this issue Mar 18, 2022 · 3 comments · Fixed by #233
Closed

Button state bug🐛 #230

AbrasiveBoar902 opened this issue Mar 18, 2022 · 3 comments · Fixed by #233
Labels
bug Something isn't working

Comments

@AbrasiveBoar902
Copy link

Describe the bug
When I click on a disabled Button ( onPressed: null ) and use setState to enable it, it will still be displayed gray as it is disabled

Like this:
Button(
child: const Text('This is a text'),
onPressed: SingletonClass.instance.buttonEnabled ? null : () {},
),

@bdlukaa
Copy link
Owner

bdlukaa commented Mar 18, 2022

Sorry, but I can't reproduce. Can you try?

Button(
  child: const Text('This is a text'),
  onPressed: SingletonClass.instance.buttonEnabled ? () {} : null,
),

@AbrasiveBoar902
Copy link
Author

AbrasiveBoar902 commented Mar 19, 2022

Sorry, but I can't reproduce. Can you try?

Button(
  child: const Text('This is a text'),
  onPressed: SingletonClass.instance.buttonEnabled ? () {} : null,
),

Well I wrote wrong in the issue. That is not my source code.
I'm using setState((){}) in a compute.then()

bandicam.2022-03-20.02-06-10-320.mp4

@AbrasiveBoar902
Copy link
Author

onPressed: () {
  GKernel.instance.converting = true;
  setState(() {});
  compute(convert, ConvertArgs(convertmethod: GKernel.instance.convertMethod, dithering: GKernel.instance.dithering)).then((value) {
    GKernel.instance.converting = false;
    setState(() {});
   });
 }),
RepaintBoundary(
  child: Button(
    child: const Text('保存为图片'),
    onPressed: GKernel.instance.converting ? null : () {},
  ),
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants