You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to flexibly control the selected color block through the code. I made a small demo and hardcoded a color 【0xffFFB400】 that did not exist in _defaultColors. When I selected the color. The expectation is that no color block will be selected, but when I click, it is still selected. The color block I clicked.
in debug mode, I found that _currColor value is 0xffFFB400, but widget is still select the wrong color block .
I'm not sure it's an issue with a package. You can just update your code with a color check, something like:
voidchangeColor(Color color) {
if (_defaultColors.contains(color)) {
setState(() => _currColor = color);
} else {
throwException('The selected color is not on the list!');
// and handle it via try/catch on other side, or just show a snackbar, etc.
}
}
If it's enough for your needs — please consider closing the issue. Thanks!
I think what the OP was asking for is the ability to change the selected color in the picker from the outside.
Currently, there's no way to do that once the widget has been constructed. The selected color can only be changed by interaction with the widget's UI. In the example shared above, _currColor can only be used for setting the initial value of the picker. If it changes (based on reloading backing data or something) the picker doesn't pick up that change.
I want to flexibly control the selected color block through the code. I made a small demo and hardcoded a color 【0xffFFB400】 that did not exist in _defaultColors. When I selected the color. The expectation is that no color block will be selected, but when I click, it is still selected. The color block I clicked.
in debug mode, I found that _currColor value is 0xffFFB400, but widget is still select the wrong color block .
The text was updated successfully, but these errors were encountered: