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

🐛 NumberBox when max changed, and setState(). Duplicate GlobalKey detected in widget tree. #1146

Closed
git-boya opened this issue Nov 26, 2024 · 4 comments
Labels
invalid This doesn't seem right

Comments

@git-boya
Copy link

Describe the bug
Duplicate GlobalKey detected in widget tree.

To Reproduce
Steps to reproduce the behavior:

SizedBox(
      width: 120,
      child: NumberBox(
        value: ConfigLogic.to.config.value.maxTask,
        min: 1,
        max: logic.cpuCoreCount,
        mode: SpinButtonPlacementMode.inline,
        clearButton: false,
        onChanged: (value) {
          if (value == null) return;
          ConfigLogic.to.config.update((val) => val?.maxTask = value);
          ConfigLogic.to.save();
        },
      ),
    )

change cpuCoreCount and setState()

Screenshots
image

Additional context
Add any other context about the problem here.

@WinXaito
Copy link
Collaborator

WinXaito commented Nov 26, 2024

Hello,

I tried, but I'm unable to reproduce:

NumberBox(
  value: viewModel.value,
  min: 1,
  max: viewModel.max,
  mode: SpinButtonPlacementMode.inline,
  clearButton: false,
  onChanged: (v) {
    viewModel.value = v;
  },
),
Button(child: Text('Change max'), onPressed: (){
  viewModel.max += 1;
}),

And in my viewModel:

int _max = 2;
int get max => _max;
set max(int v) {
  _max = v;
  notifyListeners();
}
int _value = 1;
int get value => _value;
set value(int? v) {
  _value = v ?? 1;
  notifyListeners();
}

It works has expected without any errors:

fluentui_numberbox


So, I think your problem is caused by something else.
Otherwise, could you provide a minimal reproductible example ?

@git-boya
Copy link
Author

Hello,

I tried, but I'm unable to reproduce:

NumberBox(
  value: viewModel.value,
  min: 1,
  max: viewModel.max,
  mode: SpinButtonPlacementMode.inline,
  clearButton: false,
  onChanged: (v) {
    viewModel.value = v;
  },
),
Button(child: Text('Change max'), onPressed: (){
  viewModel.max += 1;
}),

And in my viewModel:

int _max = 2;
int get max => _max;
set max(int v) {
  _max = v;
  notifyListeners();
}
int _value = 1;
int get value => _value;
set value(int? v) {
  _value = v ?? 1;
  notifyListeners();
}

It works has expected without any errors:

fluentui_numberbox fluentui_numberbox

So, I think your problem is caused by something else. Otherwise, could you provide a minimal reproductible example ?

Thank you for your reply. I found this problem on mac, but it did not appear on windows just now. I will try again with mac tomorrow

@WinXaito
Copy link
Collaborator

Okay.
If it still appear on Mac, you can give me a minimal reproductible example and I can also check on my mac.

@git-boya
Copy link
Author

After restarting my computer, the problem no longer occurred. It should not be related to Fluent_ui, but rather some unknown reasons.
Thanks!

@bdlukaa bdlukaa closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2024
Repository owner locked as resolved and limited conversation to collaborators Nov 27, 2024
@bdlukaa bdlukaa added invalid This doesn't seem right and removed waiting response labels Nov 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants