bizz84 / time_tracker_flutter_course

Source code for every lesson in the "Flutter & Firebase: Build a Complete App for iOS & Android" course on Udemy
https://nnbd.me/ff-udemy
MIT License
405 stars 171 forks source link

Fixed the signInWithFacebook() #10

Closed zyllus17 closed 2 years ago

zyllus17 commented 3 years ago

The FacebookLoginStatus enum should be in lower case instead of uppercase

@override
  Future<User> signInWithFacebook() async {
    final fb = FacebookLogin();
    final response = await fb.logIn(permissions: [
      FacebookPermission.publicProfile,
      FacebookPermission.email,
    ]);
    switch (response.status) {
      case FacebookLoginStatus.success:
        final accessToken = response.accessToken;
        final userCredential = await _firebaseAuth.signInWithCredential(
          FacebookAuthProvider.credential(accessToken.token),
        );
        return userCredential.user;
      case FacebookLoginStatus.cancel:
        throw FirebaseAuthException(
          code: 'ERROR_ABORTED_BY_USER',
          message: 'Sign in aborted by user',
        );
      case FacebookLoginStatus.error:
        throw FirebaseAuthException(
          code: 'ERROR_FACEBOOK_LOGIN_FAILED',
          message: response.error.developerMessage,
        );
      default:
        throw UnimplementedError();
    }
  }
zyllus17 commented 2 years ago

A lot of stuff is depreciated in the tutorial, closing the PR.