Skip to content

Commit

Permalink
fix(auth): remove listener on dispose and only call setState when mou…
Browse files Browse the repository at this point in the history
…nted (#419)
  • Loading branch information
russellwheatley authored Nov 13, 2024
1 parent 93bfe60 commit 91c982b
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions packages/firebase_ui_auth/lib/src/screens/profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,27 @@ class _EmailVerificationBadge extends StatefulWidget {
}

class _EmailVerificationBadgeState extends State<_EmailVerificationBadge> {
late final service = EmailVerificationController(widget.auth)
..addListener(() {
setState(() {});
})
..reload();
late final EmailVerificationController service;
late final VoidCallback listener;

@override
void initState() {
super.initState();
listener = () {
if (mounted) {
setState(() {});
}
};
service = EmailVerificationController(widget.auth)
..addListener(listener)
..reload();
}

@override
void dispose() {
service.removeListener(listener);
super.dispose();
}

EmailVerificationState get state => service.state;

Expand Down

0 comments on commit 91c982b

Please sign in to comment.