diff --git a/learning/tour-of-beam/frontend/lib/pages/tour/widgets/unit.dart b/learning/tour-of-beam/frontend/lib/pages/tour/widgets/unit.dart index d5c41c720395..165f542daca1 100644 --- a/learning/tour-of-beam/frontend/lib/pages/tour/widgets/unit.dart +++ b/learning/tour-of-beam/frontend/lib/pages/tour/widgets/unit.dart @@ -41,9 +41,17 @@ class _UnitWidgetState extends State { @override void initState() { super.initState(); - widget.contentTreeController.addListener(() { - setState(() {}); - }); + widget.contentTreeController.addListener(_rebuild); + } + + @override + void dispose() { + widget.contentTreeController.removeListener(_rebuild); + super.dispose(); + } + + void _rebuild() { + setState(() {}); } @override