rydmike / flex_color_picker

A highly customizable Flutter color picker.
BSD 3-Clause "New" or "Revised" License
200 stars 42 forks source link

Callback function #1

Closed aldwnesx closed 3 years ago

aldwnesx commented 3 years ago

I am trying to store the color selected into sharedpreference, but it looks like the callback function isn't working:

  color: screenPickerColor,
                onColorChanged: (Color color) {
                  print("new color ");
                  print(color);
                },
rydmike commented 3 years ago

Hi @aldwnesx,

It is a bit difficult to see from your short sample what might be wrong, but from what is shown I suspect your implementation/usage might be causing the issue.

I took the basic example included with the package and added print statements to the onColorChanged callback there for both the Card and Dialog example.

In a Card here: image

In a Dialog here: image

You can find the complete code for this modified example with the print statements baked in here: https://gist.github.com/rydmike/65d9219a5d8be61bc9b31077c531ebe3

When I use this example, the onColorChanged callback appears to be working as it should in both cases

colorpicker_issue1

If you compare your code with the example code, can you find any major differences between it and your implementation from a usage principle point of view? If you do, then that might help you solve the issue.

If it does not help, then if you provide a link to short a Gist sample or complete GitHub repo with your code, I might be able to assist further.

Mike

aldwnesx commented 3 years ago

Hello, thanks so much for your reply.

The problem seems to be gone after I restarted my PC, so weird!

Thank you for the great work!

rydmike commented 3 years ago

No problem, happy to help and that you got it to work :)