Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth): remove listener on dispose and only call setState when mounted #419

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading