How to guard setState with the mounted check after an async gap in Flutter
After an await, the widget may already be disposed, and calling setState throws. Guard the resume with if (!mounted) return; and, better, cancel the work that triggers it. The full pattern for Flutter 3.44.