From c615d3effe2da35ba131a576b99b4a00fd0fa37e Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Sun, 26 Jan 2020 13:46:22 -0300 Subject: [PATCH] Closing stream --- lib/game/game.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/game/game.dart b/lib/game/game.dart index 5d9bee187..c3b4d5428 100644 --- a/lib/game/game.dart +++ b/lib/game/game.dart @@ -61,7 +61,15 @@ abstract class Game { void onAttach() {} // Called when the Game widget is detached - void onDetach() {} + @mustCallSuper + void onDetach() { + // Keeping this here, because if we leave this on HasWidgetsOverlay + // and somebody overrides this and forgets to call the stream close + // we can face some leaks. + if (this is HasWidgetsOverlay) { + (this as HasWidgetsOverlay).widgetOverlayController.close(); + } + } } class OverlayWidget {