{
  "id": "flutter/global-key-duplicate-reparent",
  "signature": "Duplicate GlobalKey detected in widget tree: GlobalKey#abcde was used by multiple widgets",
  "signature_zh": "在小部件树中检测到重复的 GlobalKey：GlobalKey#abcde 被多个小部件使用",
  "regex": "Duplicate GlobalKey detected in widget tree: GlobalKey#[a-f0-9]+ was used by multiple widgets",
  "domain": "flutter",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A GlobalKey is assigned to more than one widget in the same widget tree, often due to improper key reuse in lists or conditional rendering.",
  "root_cause_type": "generic",
  "root_cause_zh": "同一个 GlobalKey 被分配给了同一小部件树中的多个小部件，通常是由于列表或条件渲染中不当的键重用。",
  "versions": [
    {
      "version": "Flutter 3.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Dart 3.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Remove the GlobalKey entirely from all widgets",
      "why_fails": "GlobalKeys are often needed for state preservation or form validation; removing them may break functionality.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a static GlobalKey variable shared across widgets",
      "why_fails": "A static key is still a single instance; if used in multiple widgets, it will cause the same duplicate error.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure each widget has a unique GlobalKey by generating a new key per instance. Example: ListView.builder(itemBuilder: (context, index) => MyWidget(key: GlobalKey(), data: items[index]));",
      "success_rate": 0.95,
      "how": "Ensure each widget has a unique GlobalKey by generating a new key per instance. Example: ListView.builder(itemBuilder: (context, index) => MyWidget(key: GlobalKey(), data: items[index]));",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use ValueKey or ObjectKey instead of GlobalKey if state preservation is not required for every widget. Example: ListView(children: items.map((item) => MyWidget(key: ValueKey(item.id))).toList());",
      "success_rate": 0.9,
      "how": "Use ValueKey or ObjectKey instead of GlobalKey if state preservation is not required for every widget. Example: ListView(children: items.map((item) => MyWidget(key: ValueKey(item.id))).toList());",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using a GlobalKey for a form, store it in a map keyed by unique identifiers. Example: Map<String, GlobalKey<FormState>> formKeys = {};",
      "success_rate": 0.85,
      "how": "If using a GlobalKey for a form, store it in a map keyed by unique identifiers. Example: Map<String, GlobalKey<FormState>> formKeys = {};",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure each widget has a unique GlobalKey by generating a new key per instance. Example: ListView.builder(itemBuilder: (context, index) => MyWidget(key: GlobalKey(), data: items[index]));",
    "Use ValueKey or ObjectKey instead of GlobalKey if state preservation is not required for every widget. Example: ListView(children: items.map((item) => MyWidget(key: ValueKey(item.id))).toList());",
    "If using a GlobalKey for a form, store it in a map keyed by unique identifiers. Example: Map<String, GlobalKey<FormState>> formKeys = {};"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://api.flutter.dev/flutter/widgets/GlobalKey-class.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-07-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}