I wrote the code according to the sample that gives an error, but I'm trying to implement Twitter login

50 Views Asked by At

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;
                    }
0

There are 0 best solutions below