GlobalObjectKey<T extends State<StatefulWidget>> class Null safety

A global key that takes its identity from the object used as its value.

Used to tie the identity of a widget to the identity of an object used to generate that widget.

If the object is not private, then it is possible that collisions will occur where independent widgets will reuse the same object as their GlobalObjectKey value in a different part of the tree, leading to a global key conflict. To avoid this problem, create a private GlobalObjectKey subclass, as in:

class _MyKey extends GlobalObjectKey {
  const _MyKey(Object value) : super(value);
}

Since the runtimeType of the key is part of its identity, this will prevent clashes with other GlobalObjectKeys even if they have the same value.

Any GlobalObjectKey created for the same value will match.

Inheritance
Annotations

Constructors

GlobalObjectKey(Object value)
Creates a global key that uses identical on value for its operator==.
const

Properties

currentContext BuildContext?
The build context in which the widget with this key builds.
read-onlyinherited
currentState → T?
The State for the widget in the tree that currently has this global key.
read-onlyinherited
currentWidget Widget?
The widget in the tree that currently has this global key.
read-onlyinherited
hashCode int
The hash code for this object.
read-onlyoverride
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
value Object
The object whose identity is used by this key's operator==.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override