@@ -77,18 +77,19 @@ class FirebaseAuthService extends ChangeNotifier {
7777 try {
7878 final userCredential = await _auth.signInWithPopup (GithubAuthProvider ());
7979 _user = userCredential.user;
80- } catch (error) {
80+ } on FirebaseAuthException catch (error) {
8181 // If email of Github account already registered in Frebase but with
8282 // Google provider, we need to sign in with Google provider first,
8383 // then link the GitHub provider to Google provider.
84- if (error is FirebaseAuthException &&
85- error.code == 'account-exists-with-different-credential' ) {
84+ if (error.code == 'account-exists-with-different-credential' ) {
8685 debugPrint ('google account exists, signing in with google' );
8786 await _signInWithGoogle ();
8887 await _linkWithGithub ();
8988 return ;
9089 }
9190 debugPrint ('signin with github failed: $error ' );
91+ } catch (error) {
92+ debugPrint ('signin with github failed: $error ' );
9293 }
9394 }
9495
@@ -125,16 +126,16 @@ class FirebaseAuthService extends ChangeNotifier {
125126 _user = userCredential? .user;
126127 notifyListeners ();
127128 await _auth.currentUser? .getIdToken (true );
128- } catch (error) {
129- // If Google account's credential already exists in firebase, we going to
130- // link github account to google.
131- if (error is FirebaseAuthException &&
132- error.code == 'credential-already-in-use' ) {
129+ } on FirebaseAuthException catch (error) {
130+ // If Github account's credential already exists in firebase, we going to
131+ // link google account to github.
132+ if (error.code == 'credential-already-in-use' ) {
133133 await _relinkGithubToGoogle ();
134134 return ;
135135 }
136136 debugPrint ('linkWithGoogle failed: $error ' );
137- //
137+ } catch (error) {
138+ debugPrint ('linkWithGoogle failed: $error ' );
138139 }
139140 // If linking google succeeded, we need to unlink it and relink
140141 // github to google to make google primary.
0 commit comments