Unverified Commit 1c852ced authored by Dan Field's avatar Dan Field Committed by GitHub

Do not assert callbacks contains key if disposed (#104292)

parent 6631e63e
......@@ -214,7 +214,7 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
}());
};
return () {
assert(_callbacks.containsKey(callbackId));
assert(debugDisposed || _callbacks.containsKey(callbackId));
_callbacks.remove(callbackId);
_updateSubtreeCompositionObserverCount(-1);
};
......
......@@ -965,6 +965,21 @@ void main() {
expect(root.subtreeHasCompositionCallbacks, false);
expect(a1.subtreeHasCompositionCallbacks, false);
});
test('Double removing a observe callback throws', () {
final ContainerLayer root = ContainerLayer();
final VoidCallback callback = root.addCompositionCallback((_) { });
callback();
expect(() => callback(), throwsAssertionError);
});
test('Removing an observe callback on a disposed layer does not throw', () {
final ContainerLayer root = ContainerLayer();
final VoidCallback callback = root.addCompositionCallback((_) { });
root.dispose();
expect(() => callback(), returnsNormally);
});
}
class FakeEngineLayer extends Fake implements EngineLayer {
......
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