Commit af8019bf authored by Adam Barth's avatar Adam Barth

Merge pull request #1355 from abarth/current_state

Add a currentWidget and currentState accessor to GlobalKeys
parents 6c3b20be 80997a68
......@@ -92,6 +92,15 @@ abstract class GlobalKey extends Key {
}
}
Element get currentElement => _registry[this];
Widget get currentWidget => currentElement?.widget;
State get currentState {
Element element = currentElement;
if (element is StatefulComponentElement)
return element.state;
return null;
}
static void registerRemoveListener(GlobalKey key, GlobalKeyRemoveListener listener) {
assert(key != null);
Set<GlobalKeyRemoveListener> listeners =
......@@ -109,11 +118,6 @@ abstract class GlobalKey extends Key {
assert(removed);
}
static Element getElement(GlobalKey key) {
assert(key != null);
return _registry[key];
}
// TODO(ianh): call this
static void _notifyListeners() {
assert(() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment