GlobalObjectKey<T extends State<StatefulWidget>> class

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.

Any GlobalObjectKey created for the same object will match.

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

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.
no setterinherited
currentState → T?
The State for the widget in the tree that currently has this global key.
no setterinherited
currentWidget Widget?
The widget in the tree that currently has this global key.
no setterinherited
hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value Object
The object whose identity is used by this key's operator==.
final

Methods

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

Operators

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