Assert binding ready before getting a11y listener

This adds an assert to verify that we have already got a binding when we
get a semantics listener. Otherwise we crash. (I mean, we still crash,
but now in checked mode we crash on an assert instead. Progress?)
This commit is contained in:
Hixie 2016-03-07 16:36:09 -08:00
parent 1568b8277c
commit 3d802075e2

View File

@ -349,8 +349,10 @@ class SemanticsNode extends AbstractNode {
static bool get hasListeners => _listeners != null && _listeners.length > 0;
static VoidCallback onSemanticsEnabled; // set by the binding
static void addListener(mojom.SemanticsListener listener) {
if (!hasListeners)
if (!hasListeners) {
assert(onSemanticsEnabled != null); // initialise the binding _before_ adding listeners
onSemanticsEnabled();
}
_listeners ??= <mojom.SemanticsListener>[];
_listeners.add(listener);
}