Facebook graph api 登录时出现Facebook黑屏
我正在尝试使用Fatter_facebook_登录,每次单击与该方法相关的按钮,我都会看到一个暗淡的屏幕,但没有facebook登录页面 我已经更新到最新版本的依赖项,不确定问题出在哪里Facebook graph api 登录时出现Facebook黑屏,facebook-graph-api,flutter,flutter-dependencies,Facebook Graph Api,Flutter,Flutter Dependencies,我正在尝试使用Fatter_facebook_登录,每次单击与该方法相关的按钮,我都会看到一个暗淡的屏幕,但没有facebook登录页面 我已经更新到最新版本的依赖项,不确定问题出在哪里 dependencies: flutter_facebook_login: ^2.0.0 http: ^0.12.0+2 json_annotation: ^2.0.0 void initiateFacebookLogin() async { var facebookLogin =
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()));
});
}
依赖项:
Fatter_facebook_登录:^2.0.0
http:^0.12.0+2
json_批注:^2.0.0
void initiateFacebookLogin()异步{
var facebookLogin=facebookLogin();
var facebookLoginResult=等待facebookLogin
.logInWithReadPermissions(['email','public_profile']);
开关(facebookLoginResult.状态){
案例FacebookLoginStatus.error:
打印(“错误”);
onLoginStatusChanged(false);
打破
case FacebookLoginStatus.Cancelled By用户:
打印(“用户取消”);
onLoginStatusChanged(false);
打破
案例FacebookLoginStatus.loggedIn:
最终令牌=facebookLoginResult.accessToken.token;
_令牌=令牌;
//final graphResponse=等待http.get(
// 'https://graph.facebook.com/v2.12/me?fields=name,名字,姓氏,电子邮件和访问令牌=$token');
//最终配置文件=jsonDecode(graphResponse.body);
//打印(个人资料);
打印(_令牌);
打破
}
}
无效用户登录(字符串标记){
字符串grantType=“”;
字符串clientId='';
字符串clientSecret='';
字符串后端=“”;
字符串userType='';
最终地图登录={
“转换令牌”:grantType,
“fLdfosdlfaisodfjaosdnaiscalsfa”:客户ID,
“Sdfasfererwa”:
客户机密,
“facebook”:后端,
_令牌:令牌,
“客户”:用户类型,
};
http
.post('http://localhost:127.0.0.1/api/social/convert-令牌/',
正文:json.encode(登录))
.然后((http.Response){
最终映射responseData=json.decode(response.body);
打印(应答数据);
});
}
void backendToken(){
设置状态(){
字符串标记;
打印(代币);
});
}
bool isLoggedIn=false;
void onloginstatus已更改(bool isLoggedIn){
设置状态(){
this.isLoggedIn=isLoggedIn;
打印(“用户已登录”);
用户登录(_令牌);
导航器.of(上下文).pushReplacement(新材料路线)(
生成器:(BuildContext上下文)=>NavigationPage());
});
}
我想在调用initiateFacebookLogin函数时登录facebook