Commit 1c852ce 1 parent 6631e63 commit 1c852ce Copy full SHA for 1c852ce
File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -214,7 +214,7 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
214
214
}());
215
215
};
216
216
return () {
217
- assert (_callbacks.containsKey (callbackId));
217
+ assert (debugDisposed || _callbacks.containsKey (callbackId));
218
218
_callbacks.remove (callbackId);
219
219
_updateSubtreeCompositionObserverCount (- 1 );
220
220
};
Original file line number Diff line number Diff line change @@ -965,6 +965,21 @@ void main() {
965
965
expect (root.subtreeHasCompositionCallbacks, false );
966
966
expect (a1.subtreeHasCompositionCallbacks, false );
967
967
});
968
+
969
+ test ('Double removing a observe callback throws' , () {
970
+ final ContainerLayer root = ContainerLayer ();
971
+ final VoidCallback callback = root.addCompositionCallback ((_) { });
972
+ callback ();
973
+
974
+ expect (() => callback (), throwsAssertionError);
975
+ });
976
+
977
+ test ('Removing an observe callback on a disposed layer does not throw' , () {
978
+ final ContainerLayer root = ContainerLayer ();
979
+ final VoidCallback callback = root.addCompositionCallback ((_) { });
980
+ root.dispose ();
981
+ expect (() => callback (), returnsNormally);
982
+ });
968
983
}
969
984
970
985
class FakeEngineLayer extends Fake implements EngineLayer {
You can’t perform that action at this time.
0 commit comments