Я пытаюсь использовать flutter_facebook_login, и каждый раз, когда я нажимаю кнопку, связанную с методом, я получаю затемненный экран, но на странице входа в Facebook нет.
Я обновился до последней версии зависимости и не уверен, в чем проблема.
dependencies:
flutter_facebook_login: ^2.0.0
http: ^0.12.0+2
json_annotation: ^2.0.0
void initiateFacebookLogin() async {
var facebookLogin = FacebookLogin();
var facebookLoginResult = await facebookLogin
.logInWithReadPermissions(['email', 'public_profile']);
switch (facebookLoginResult.status) {
case FacebookLoginStatus.error:
print("Error");
onLoginStatusChanged(false);
break;
case FacebookLoginStatus.cancelledByUser:
print("CancelledByUser");
onLoginStatusChanged(false);
break;
case FacebookLoginStatus.loggedIn:
final token = facebookLoginResult.accessToken.token;
_token = token;
// final graphResponse = await http.get(
// 'https://graph.facebook.com/v2.12/me?fields=name,first_name,last_name,email&access_token=$token');
// final profile = jsonDecode(graphResponse.body);
// print(profile);
print(_token);
break;
}
}
void userLogin(String token) {
String grantType = '';
String clientId = '';
String clientSecret = '';
String backend = '';
String userType = '';
final Map<String, dynamic> logIn = {
'convert_token': grantType,
'fLdfosdlfaisodfjaosdnaiscalsfa': clientId,
'sdfasfasfererwa':
clientSecret,
'facebook': backend,
_token: token,
'customer': userType,
};
http
.post('http://localhost:127.0.0.1/api/social/convert-token/',
body: json.encode(logIn))
.then((http.Response response) {
final Map<String, dynamic> responseData = json.decode(response.body);
print(responseData);
});
}
void backendToken() {
setState(() {
String token;
print(token);
});
}
bool isLoggedIn = false;
void onLoginStatusChanged(bool isLoggedIn) {
setState(() {
this.isLoggedIn = isLoggedIn;
print('User is logged in');
userLogin(_token);
Navigator.of(context).pushReplacement(new MaterialPageRoute(
builder: (BuildContext context) => NavigationPage()));
});
}
Я хочу войти в Facebook, когда вызывается функция initiateFacebookLogin.