0

I'm trying to implement Twitter login and have the following SDK installed.

・twitter_login: ^4.0.1 (https://pub.dev/packages/twitter_login)

So I'm trying with almost the same code in the ReadME, but I'm having trouble with a red wavy line appearing under the code.

error code :

    switch (authResult.status) {

The getter 'status' isn't defined for the type 'Future'. Try importing the library that defines 'status', correcting the name to the name of an existing getter, or defining a getter or field named 'status'. Open documentation

code↓

                    final twitterLogin = TwitterLogin(
                      apiKey: '??????',
                      apiSecretKey: '?????',
                      redirectURI: 'example://??????',
                    );
                    final authResult = twitterLogin.login();
                    switch (authResult.status) {
                      case TwitterLoginStatus.loggedIn:
                      // success
                        print('====login success====');
                        final credential = TwitterAuthProvider.credential(
                          accessToken: authResult.authToken,
                          secret: authResult.authTokenSecret,
                        );
                        // await FirebaseAuth.instance.signInWithCredential(credential);

                        await FirebaseAuth.instance.currentUser!.linkWithCredential(credential).then((value) {
                          Navigator.push(
                              context,
                              MaterialPageRoute(builder: (context) => MyHomePage(),
                              )
                          );
                        });

                        break;
                      case TwitterLoginStatus.cancelledByUser:
                      // cancel
                        print('====login cancel====');
                        break;
                      case TwitterLoginStatus.error:
                      // error
                        print('====login error====');
                        break;
                    }
2
  • 1
    Never post images of code, data or error messages. Please edit your question and include copy/paste the text into the question, formatted. This is so that we can try to reproduce the problem without having to re-type everything, and your question can be properly indexed or read by screen readers.
    – RiggsFolly
    Dec 31, 2021 at 13:49
  • Thank you for your advice, so I edited the question
    – 24k
    Jan 1, 2022 at 5:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.