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
{{ message }}
Repository navigation
API doc clarification request: if a key is not provided for a widget, what is default key? #13787
changed the title [-]API doc clarification request: if a key is not provided for a widget, what happens?[/-][+]API doc clarification request: if a key is not provided for a widget, what is default "key"?[/+]on Dec 28, 2017
Also we could add the following when adding docs to keys:
Basically any time you're building a list of widgets from a list of data, and the list might change, you should key the children, so that we keep the subtrees tied to the data. Otherwise, we won't know what's going on and if anything is stateful the state could spill from one to the other (what's really going on is that the data is spilling from one to the other -- we have no way to distinguish "each item changed its data" from "one of the items was removed/added and pushed all the other items around" without keys).
Generally the best key to use is a ValueKey where T is the type of the data you're generating the widgets from, assuming that each such datum is unique. (In particular, no need to use toString.)
Several people (including at least one flutter team member) have been bitten recently by the confusion mentioned by Ian. Would be nice to add language like his to the docs sooner rather than later.
changed the title [-]API doc clarification request: if a key is not provided for a widget, what is default "key"?[/-][+]API doc clarification request: if a key is not provided for a widget, what is default key?[/+]on Jan 13, 2020
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
[-]API doc clarification request: if a key is not provided for a widget, what happens?[/-][+]API doc clarification request: if a key is not provided for a widget, what is default "key"?[/+]Hixie commentedon Jan 2, 2018
The default key is null, i.e. no key.
Hixie commentedon Jan 2, 2018
Also we could add the following when adding docs to keys:
wmleler commentedon Jan 2, 2018
Several people (including at least one flutter team member) have been bitten recently by the confusion mentioned by Ian. Would be nice to add language like his to the docs sooner rather than later.
[-]API doc clarification request: if a key is not provided for a widget, what is default "key"?[/-][+]API doc clarification request: if a key is not provided for a widget, what is default key?[/+]pedromassangocode commentedon Jul 22, 2020
Found in the current docmunetation because it does not state what it the default key value when not provided.
I looked at the following links:
https://docs.flutter.io/flutter/foundation/Key-class.html
https://docs.flutter.io/flutter/widgets/Widget/key.html
danagbemava-nc commentedon Nov 1, 2022
The current documentation does not state which key is used either.
I checked the following links:
https://api.flutter.dev/flutter/widgets/Widget/key.html
https://api.flutter.dev/flutter/foundation/Key-class.html
document that the default Key is null and explain proper usage in lis…
document that the default Key is null and explain proper usage in lis…
github-actions commentedon Jul 14, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.