Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Check mount state before setState calls
  • Loading branch information
stuartmorgan-g committed Jun 25, 2025
commit b6a617d7c2a6fedb18a825e4c520327075ff135e
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class SignInDemoState extends State<SignInDemo> {
// Add your client IDs here as necessary for your supported platforms.
);
signIn.authenticationEvents.listen((GoogleSignInAuthenticationEvent event) {
if (!mounted) {
return;
}
setState(() {
switch (event) {
case GoogleSignInAuthenticationEventSignIn():
Expand All @@ -74,6 +77,9 @@ class SignInDemoState extends State<SignInDemo> {
}

void _updateAuthorization(GoogleSignInClientAuthorization? authorization) {
if (!mounted) {
return;
}
setState(() {
_authorization = authorization;
});
Expand All @@ -95,6 +101,9 @@ class SignInDemoState extends State<SignInDemo> {

Future<void> _handleGetContact(
GoogleSignInClientAuthorization authorization) async {
if (!mounted) {
return;
}
setState(() {
_contactText = 'Loading contact info...';
});
Expand All @@ -116,13 +125,15 @@ class SignInDemoState extends State<SignInDemo> {
final String? firstNamedContactName =
_pickFirstNamedContact(response.connections);

setState(() {
if (firstNamedContactName != null) {
_contactText = 'I see you know $firstNamedContactName!';
} else {
_contactText = 'No contacts to display.';
}
});
if (mounted) {
setState(() {
if (firstNamedContactName != null) {
_contactText = 'I see you know $firstNamedContactName!';
} else {
_contactText = 'No contacts to display.';
}
});
}
}

String? _pickFirstNamedContact(List<Person>? connections) {
Expand Down