0

What is the main cause of the above error in Flutter? I am simply using the following code, where both the pickers use same code to fetch data from different json.

 if (_equipmentSwitch == equipmentType.Implement)
          TractorPicker(mapNotifier: modelNotifier)
        else
          HarvesterPicker(mapNotifier: modelNotifier),

HarvesterPicker is working fine. But if I switch to tractorPicker, I get the above error along with this error "Duplicate GlobalKey detected in widget tree" . But I have never used a global key

Sindu
  • 131
  • 1
  • 10

1 Answers1

0

Found the solution:

Since I was using the same ValueNotifier(modelNotifier) for both the pickers, this error occured. Used dispose method to erase the memory of modelNotifier.

@override
void dispose() {
  modelNotifier.dispose();
  super.dispose();
}

This solved my problem.

AgainPsychoX
  • 1,527
  • 1
  • 16
  • 20
Sindu
  • 131
  • 1
  • 10