# Duplicate GlobalKey detected in widget tree: GlobalKey#abcde was used by multiple widgets

- **ID:** `flutter/global-key-duplicate-reparent`
- **Domain:** flutter
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Flutter 3.10.0 | active | — | — |
| Dart 3.0.0 | active | — | — |

## Workarounds

1. **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]));** (95% success)
   ```
   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]));
   ```
2. **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());** (90% success)
   ```
   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());
   ```
3. **If using a GlobalKey for a form, store it in a map keyed by unique identifiers. Example: Map<String, GlobalKey<FormState>> formKeys = {};** (85% success)
   ```
   If using a GlobalKey for a form, store it in a map keyed by unique identifiers. Example: Map<String, GlobalKey<FormState>> formKeys = {};
   ```

## Dead Ends

- **Remove the GlobalKey entirely from all widgets** — GlobalKeys are often needed for state preservation or form validation; removing them may break functionality. (70% fail)
- **Use a static GlobalKey variable shared across widgets** — A static key is still a single instance; if used in multiple widgets, it will cause the same duplicate error. (80% fail)
